필터 지우기
필터 지우기

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

조회 수: 1 (최근 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