Thread Subject: Focus loss using keypresses in 'listbox' GUI control

Subject: Focus loss using keypresses in 'listbox' GUI control

From: Ian Clarkson

Date: 12 May, 2008 14:16:04

Message: 1 of 3

Hi everybody,

I'm having some issues with R12.1 trying to do a GUI to
display images. I have a list of files in a listbox, and I
want the axis in the GUI to update with the image that's
selected in the listbox. It currently works fine with a
mouse-click, but I want it to update as I move the
highlighted file in the listbox with the arrow keys. The
highlighting works fine UNTIL I try to draw the image. In
the callback function for the listbox, I have:

axes(handles.axesSampleImage);
imshow(data);

If I comment out these two lines, the arrow keys continue to
slide the selected string around. However, once the axes()
command is issued (even by itself) or imshow (again, even by
itself), the up and down keypresses start going through
previous/next MATLAB commands back in the main window.

I've tried returning focus to the listbox by setting its
visibility off and then on again, and setting focus back to
the figure by calling figure(myhandle). Neither works. I'm
not sure what's changing with the axes() and/or imshow()
commands that makes the GUI lose the ability to send
keypresses to the listbox.

Thanks!

Subject: Focus loss using keypresses in 'listbox' GUI control

From: matt dash

Date: 12 May, 2008 15:18:03

Message: 2 of 3

I have a similar setup where you can scroll through
variables in a list and they are plotted, and it works fine.
(With no need to re-set focus). Maybe try using the image
command instead of imshow, and specify the axes as a
property of the image instead of using the axes command.

Subject: Focus loss using keypresses in 'listbox' GUI control

From: Ian Clarkson

Date: 12 May, 2008 16:38:04

Message: 3 of 3

"matt dash" <n.a@mail.com> wrote in message
<g09n3b$ik6$1@fred.mathworks.com>...
> I have a similar setup where you can scroll through
> variables in a list and they are plotted, and it works fine.
> (With no need to re-set focus). Maybe try using the image
> command instead of imshow, and specify the axes as a
> property of the image instead of using the axes command.

Wicked -- that's totally the solution. Create an image
object using the image() function, then set its properties
accordingly. Focus does not change and the keypresses still
work.

Thanks so much!

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
axes Ian Clarkson 12 May, 2008 10:20:23
gui Ian Clarkson 12 May, 2008 10:20:23
listbox Ian Clarkson 12 May, 2008 10:20:23
focus Ian Clarkson 12 May, 2008 10:20:23
imshow Ian Clarkson 12 May, 2008 10:20:23
keypress Ian Clarkson 12 May, 2008 10:20:23
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com