why does pushing buttons affects my GUI?

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?

 Respuesta aceptada

Matt Fig
Matt Fig el 11 de Oct. de 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 comentarios

Walter Roberson
Walter Roberson el 11 de Oct. de 2012
I have never seen a uicontrol blinking. Is that an MS Windows specific feature?
Matt Fig
Matt Fig el 11 de Oct. de 2012
Haha! That made me laugh, Walter.
I meant that the cursor in the editbox will be "blinking" like, to go on and off. I don't know if there is a technical term for it...
Walter Roberson
Walter Roberson el 11 de Oct. de 2012
Ah, the winking blinking cursor, yes, that makes sense.
In the old days, whether the cursor blinked or not was something controlled by a DIP switch... (Odd.. my memory is presenting a distinct image of the 4th switch to the left on the second DIP switch of the VT100 clone the Heath H19... What a waste of neurons!)
Jan
Jan el 11 de Oct. de 2012
Editada: Jan el 11 de Oct. de 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 el 11 de Oct. de 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..

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Interactive Control and Callbacks en Centro de ayuda y File Exchange.

Preguntada:

el 11 de Oct. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by