How to extract information from a 'WindowButtonUpFcn'?

9 ビュー (過去 30 日間)
Alon Rozen
Alon Rozen 2016 年 11 月 14 日
コメント済み: Alon Rozen 2016 年 11 月 14 日
Hi all,
I am using 'WindowButtonDownFcn' in a figure to do some work when I use the mouse. So my code includes a declaration of that function:
My_Figure.WindowButtonDownFcn = {@Do_When_Mouse_Button_pressed,Var_1,Var_2};
Of course, inside 'Do_When_Mouse_Button_pressed' I have a code saying what do do when the mouse button is up again. So is looks something like this:
function Do_When_Mouse_Button_pressed(src,Var_1,Var_2)
src.WindowButtonUpFcn = @Do_When_Mouse_Button_Released;
My problem is that I want to get some variables out from 'Do_When_Mouse_Button_Released'. I cannot figure out how to do that. The usual way of using:
[src.WindowButtonUpFcn,My_Ans] = @Do_When_Mouse_Button_Released;
Together with:
function My_Ans = Do_When_Mouse_Button_Released(src,Vars)
doesn't work.
Can anyone help?
Thanks,
Alon

採用された回答

Walter Roberson
Walter Roberson 2016 年 11 月 14 日
Callbacks are always provided with two arguments, source object, and event description. You only allowed for one automatic argument, source object.
It is not possible to return anything from a callback function, except if that callback is acting as a filter such as a position constraint callback.
  1 件のコメント
Alon Rozen
Alon Rozen 2016 年 11 月 14 日
Thanks Walter,
I read carefully the attached link and understood. I solved it by sending down the main GUI handle, together with its hObject, and then wrote to it some results and saved it by using guidata function. I see that there is no simple workaround.
Thanks again!

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

その他の回答 (0 件)

カテゴリ

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