why does pushing buttons affects my GUI?

2 visualizzazioni (ultimi 30 giorni)
alex
alex il 11 Ott 2012
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?

Risposta accettata

Matt Fig
Matt Fig il 11 Ott 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 Commenti
Jan
Jan il 11 Ott 2012
Modificato: Jan il 11 Ott 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 il 11 Ott 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..

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by