How can I get a different values from a gui button, depending on if it's up or down?

2 次查看(过去 30 天)
Hello,
I'm new to matlab.
I'm creating a gui where I want a different value in a specific variable (say, buttonValue), depending on if the user is currently holding down a button or if they are not holding down that button.
I want to be able to do two things with this information.
1. run code only while it is pushed down (using an if statement, presumably)
2. be able to access the value of buttonValue in other parts of my code (using get(), presumably)
From what I've looked up, push buttons only cause a section of code to run; they can't store a value of up or down. Toggle buttons have to be pushed twice for their value to change. Neither of these seems to work for what I'm looking for.
Thank you, in advance, for your help.
edit: To be more clear:
While the left mouse button is held down over this button, buttonValue should equal 1.
While the left mouse button is not held down over this button, buttonValue should equal 0.
  2 个评论
Jan
Jan 2015-3-9
Toggle button do not have to be pushed twice to change their value. Thjere I do not understand, what you exactly want. What do you mean by "push"? Clicking with the mouse while the mouse is still down? Or is it enough if the event is triggered, when the mouse button is released?
Matlab_Learner
Matlab_Learner 2015-3-9
Thank you for your response. To be more clear:
While the left mouse button is held down over this button, buttonValue should equal 1.
While the left mouse button is not held down over this button, buttonValue should equal 0.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by