why does pushing buttons affects my GUI?

1 view (last 30 days)
I have a code that originaly started working (counting spacebar taps) as it should,without the need to press the mouse buttons before. like in this code suggested by Jarrod Rivituso- http://www.mathworks.com/matlabcentral/answers/47698-how-to-count-key-presses-in-limited-time
now, after I have added a few text UIconrols and buttons to my GUI, somehow when it returns to the main figure and I press the space key nothing happens.
only after pressing with the mouse buttons inside the figure area, the GUI will start counting as soon as I press the spacebar. my code can be seen in this link- https://docs.google.com/document/d/1-Jegvum5IQKZZBeyKqmVmQa0wvKG4QgAqoYochbS8Jk/edit
how can I change it so that I won't have to press a mouse button before the spacebar presses?

Accepted Answer

Matt Fig
Matt Fig on 11 Oct 2012
You might want to use the WindowKeypressfcn instead. Having said that, you might want to consider your overall design. Part of designing a GUI is making it so that the user can tell what to do and errors are minimized. If I run your GUI, I can see you want me to enter a number, but it is not clear where. If you put this line in your code after all the uicontrol creation:
uicontrol(a4)
Then the editbox will be blinking at startup. This makes it intuitive. Then you might want to consider that when the user hits return after entering the number, another instruction becomes invisible telling them to begin hitting the spacebar, or whatever.
  5 Comments
Jan
Jan on 11 Oct 2012
Edited: Jan on 11 Oct 2012
@Walter: See FEX: uiFlash. Useful for e.g.: A GUI with more than 5 elements (edit fields, popups etc) and a "Start" button. The user can apply the selections in arbitrary order. When the Start button is pressed, the consistency of the selections is checked and conflicting UI-controls are high-lighted.
alex
alex on 11 Oct 2012
thanks Matt, but the Windowkeypressfnc doesn't seem to make any difference.. it still waits for a mouse click on the figure, and only then it starts counting taps after pressing the spacebar..
the blinker is a good idea..
about the visibility- I do have as you maybe read in my code, another instructions becoming visible after entering the number, that say to the user to start hitting the space..
but the counter doesn't seem to work , until there is a mouse press before it..

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Objects in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!