Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
gui, playing with figures

Subject: gui, playing with figures

From: Tomas Schiler

Date: 4 Sep, 2009 08:43:03

Message: 1 of 7

Hello,
I have small problem. I would like to make gui for displaying data. User should be able to create figure (or figures) and then add data. To make it look as I wish I need couple of things and i am not sure that it is possible to make in in matlab …SO is possible to get pointers to all actual open figures? Is possible from gui to get information that user clicked on some figure with data? Is possible to get information about order of open figures?
Thanks for all suggestions

Subject: gui, playing with figures

From: us

Date: 4 Sep, 2009 09:07:02

Message: 2 of 7

"Tomas Schiler" <excal@atlas.cz> wrote in message <h7qjun$hfs$1@fred.mathworks.com>...
> Hello,
> I have small problem. I would like to make gui for displaying data. User should be able to create figure (or figures) and then add data. To make it look as I wish I need couple of things and i am not sure that it is possible to make in in matlab …SO is possible to get pointers to all actual open figures? Is possible from gui to get information that user clicked on some figure with data? Is possible to get information about order of open figures?
> Thanks for all suggestions

yes, all you want is possible...
to be more specific, you need to come up with an exemplary code snippet...

also, look at matt fig's great FEX contribution, which might come with an example for you...

http://www.mathworks.fr/matlabcentral/fileexchange/24861

us

Subject: gui, playing with figures

From: Tomas Schiler

Date: 8 Sep, 2009 12:12:04

Message: 3 of 7

"us " <us@neurol.unizh.ch> wrote in message <h7qlbm$2mp$1@fred.mathworks.com>...
> "Tomas Schiler" <excal@atlas.cz> wrote in message <h7qjun$hfs$1@fred.mathworks.com>...
> > Hello,
> > I have small problem. I would like to make gui for displaying data. User should be able to create figure (or figures) and then add data. To make it look as I wish I need couple of things and i am not sure that it is possible to make in in matlab …SO is possible to get pointers to all actual open figures? Is possible from gui to get information that user clicked on some figure with data? Is possible to get information about order of open figures?
> > Thanks for all suggestions
>
> yes, all you want is possible...
> to be more specific, you need to come up with an exemplary code snippet...
>
> also, look at matt fig's great FEX contribution, which might come with an example for you...
>
> http://www.mathworks.fr/matlabcentral/fileexchange/24861
>
Hello
I went through the FEX contribution and in helped me in some problems. However I still don’t know how to detect that some of my figures went in frond (become focused). I will try to describe what I would like to achieve on easy example. I have this easy gui. When user presses button it makes plot and set title to string value written in textbox.

S.fh = figure('units','pixels',...
              'position',[500 500 350 50],...
              'menubar','none',...
              'numbertitle','off',...
              'name','GUI_20',...
              'resize','off');
S.ed = uicontrol('style','edit',...
                 'units','pixels',...
                 'position',[10 10 220 30],...
                 'fontsize',14,...
                 'string','Enter Title');
S.pb = uicontrol('style','push',...
                 'units','pixels',...
                 'position',[240 10 100 30],...
                 'fonts',14,...
                 'str','creat figure',...
                 'callback',{@pb_call,S});
           
function [] = pb_call(varargin)
% Callback for the button labeled PUSH_1.
S = varargin{3}; % Get the structure.
figure
plot(rand(10,1));
title(get(S.ed,'String'));


 And I would like to find a way how to add ability that when you click on some created figure (it become focused) the string in text box will change to title of focused figure. I couldnt do it with WindowButtonDownFcn. Only options i can think of is to start new thread an let it check every 5s which figure is focused but i don't like this solution.
Thank you


> us

Subject: gui, playing with figures

From: Matt Fig

Date: 8 Sep, 2009 16:47:03

Message: 4 of 7

Your code could be modified this way to do what you want:

function [] = mygui()

S.fh = figure('units','pixels',...
              'position',[500 500 350 50],...
              'menubar','none',...
              'numbertitle','off',...
              'name','GUI_20',...
              'resize','off');
S.ed = uicontrol('style','edit',...
                 'units','pixels',...
                 'position',[10 10 220 30],...
                 'fontsize',14,...
                 'string','Enter Title');
S.pb = uicontrol('style','push',...
                 'units','pixels',...
                 'position',[240 10 100 30],...
                 'fonts',14,...
                 'str','creat figure',...
                 'callback',{@pb_call,S});
           
    function [] = pb_call(varargin)
        L = length(S.fh);
        S.fh(L+1) = figure('windowbuttondownfcn',{@fh_wbdfcn},...
                           'deletefcn',{@fh_dfcn});
        plot(rand(10,1));
        S.T{L+1} = get(S.ed,'String');
        title(S.T(L+1));
        S.fh
    end

    function [] = fh_wbdfcn(varargin)
        set(S.ed,'string',S.T{S.fh(S.fh==varargin{1})})
    end

    function [] = fh_dfcn(varargin)
        S.fh(S.fh==varargin{1}) = [];
    end

end





Note I will leave the commenting up to you!

Subject: gui, playing with figures

From: Tomas Schiler

Date: 9 Sep, 2009 07:53:05

Message: 5 of 7

"Matt Fig" <spamanon@yahoo.com> wrote in message <h861q7$so8$1@fred.mathworks.com>...
> Your code could be modified this way to do what you want:
>
> function [] = mygui()
>
> S.fh = figure('units','pixels',...
> 'position',[500 500 350 50],...
> 'menubar','none',...
> 'numbertitle','off',...
> 'name','GUI_20',...
> 'resize','off');
> S.ed = uicontrol('style','edit',...
> 'units','pixels',...
> 'position',[10 10 220 30],...
> 'fontsize',14,...
> 'string','Enter Title');
> S.pb = uicontrol('style','push',...
> 'units','pixels',...
> 'position',[240 10 100 30],...
> 'fonts',14,...
> 'str','creat figure',...
> 'callback',{@pb_call,S});
>
> function [] = pb_call(varargin)
> L = length(S.fh);
> S.fh(L+1) = figure('windowbuttondownfcn',{@fh_wbdfcn},...
> 'deletefcn',{@fh_dfcn});
> plot(rand(10,1));
> S.T{L+1} = get(S.ed,'String');
> title(S.T(L+1));
> S.fh
> end
>
> function [] = fh_wbdfcn(varargin)
> set(S.ed,'string',S.T{S.fh(S.fh==varargin{1})})
> end
>
> function [] = fh_dfcn(varargin)
> S.fh(S.fh==varargin{1}) = [];
> end
>
> end
>
>
>
>
>
> Note I will leave the commenting up to you!

Thanks for you advice but I have already tried to use windowbuttondownfcn problem is that it is called only when user click inside figure but you can get figure in frond just by clicking on edge of window or by some other way and windowbuttondownfcn doesn’t realize that :( . So I am still looking for another way how to do it.

Subject: gui, playing with figures

From: Jan Simon

Date: 9 Sep, 2009 09:08:03

Message: 6 of 7

Dear Tomas Schiler!

> Thanks for you advice but I have already tried to use windowbuttondownfcn problem is that it is called only when user click inside figure but you can get figure in frond just by clicking on edge of window or by some other way and windowbuttondownfcn doesn’t realize that :( . So I am still looking for another way how to do it.

I think you need the FocusGainedCallback of the Java frame of the single figures. This is definitively a question for Yair Altman (see http://undocumentedmatlab.com).

Good luck, Jan

Subject: gui, playing with figures

From: Yair Altman

Date: 9 Sep, 2009 20:52:01

Message: 7 of 7

"Jan Simon" <matlab.THIS_YEAR@nMINUSsimon.de> wrote
> Dear Tomas Schiler!
>
> > Thanks for you advice but I have already tried to use windowbuttondownfcn problem is that it is called only when user click inside figure but you can get figure in frond just by clicking on edge of window or by some other way and windowbuttondownfcn doesn’t realize that :( . So I am still looking for another way how to do it.
>
> I think you need the FocusGainedCallback of the Java frame of the single figures. This is definitively a question for Yair Altman (see http://undocumentedmatlab.com).
>
> Good luck, Jan


Of course - happy to oblige :-)
http://undocumentedmatlab.com/blog/detecting-window-focus-events/

Yair Altman
http://UndocumentedMatlab.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us