How to wait for an event without stopping the program?
Show older comments
Hello world,
I am using a GUI which displays a list of names. When the user selects a name among this list, I want to call a function, ONLY if the name is selected more than x seconds. I don't want to use a while loop to wait the x seconds, because I don't want my program to cumulate while loops each time the user selects a name. Does anyone know how to solve this problem? Is it possible to create this kind of event/listeners in Matlab? If it is possible, how to do it? Thanks for your help
5 Comments
Walter Roberson
on 21 Oct 2015
"selects" how?
dpb
on 21 Oct 2015
Besides the query of "how", to me sounds like a very unfriendly user interface design, prone to extreme frustration on the user end.
William Afonso
on 22 Oct 2015
Guillaume
on 22 Oct 2015
Any user interface that does not behave the same as is standard for the platform is very likely to result in user frustration. Particularly, if there is no cue to the new behaviour.
The expected behaviour of a user interface is that clicking on something has an immediate effect. Not after you press on it for a number of seconds. You're making it harder to use your interface. You may find that instead of trying to adjust to your special interface, the user is simply not going to use it.
What is the rationale for forcing the user to click on the list item for a minimum amount of time? And how are you planning to emulate that for keyboard input?
Walter Roberson
on 22 Oct 2015
I could imagine that if you are using up/down to move between list selections then you would not want the selection chosen as soon as you got there because you might want to move further on (or back). I can imagine someone thinking that a good approach would be to allow this kind of movement and to consider a location selected if the user "stopped moving" the keys for long enough. However, the built-in interface for such things depends not upon timing but upon the user pressing return / enter when the item to be selected is reached.
William, pushbuttons do not have a "release" callback: they only fire when the item is clicked on.
Accepted Answer
More Answers (1)
William Afonso
on 1 Nov 2015
Categories
Find more on Loops and Conditional Statements 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!