How to check that a push button has been pressed by the user usinguicontrol?

8 ビュー (過去 30 日間)
Rida
Rida 2016 年 2 月 4 日
コメント済み: KSSV 2016 年 2 月 4 日
Hello!! I am creating a GUI, in which a user selects something from a popup menu, then a login window appears and user enters his password. After that, a figure appears showing two buttons. I want to program that if user has pressed button 1 then do some stuff and if user has pressed button 2 then do some other stuff. I am using "uicontrol" for creating push button, how can I check that user has pressed a button. I tried it using "get(h.pb1,{'Value'});" it gives me [0] every time. Kindly help!!

回答 (1 件)

KSSV
KSSV 2016 年 2 月 4 日
you have to use value = get(handles.popmenu,'Value')
value will be the respective number of strings selected in popmenu. Then you can switch between the numbers to do your conditions.
  2 件のコメント
Rida
Rida 2016 年 2 月 4 日
Thank-you, but this is giving me a [0] every time, if I press button, it gives [0] and if I do not press button it gives the same
KSSV
KSSV 2016 年 2 月 4 日
You may create a handle by yourself, say handles.switch = 1 ; for first switch and handles.switch = 2 ; for the second. So whenever the respective switch is pressed, you will get the handles.switch value.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by