Prev: simulink error while conversion from serial to parallel using buffer
Next: using value from previous iteration-fminunc
From: Jean on 19 May 2010 15:50 Hello to all of you Matlab fans, I have a GUI composed of 3 axes, 2 buttons and a listbox. From the first button I load 3 signals and plot each of them them into an axis. The second button plots in each axes a detection curve in red. When I click on the white background of the axes the program does what I want (calculates the current point position, gives me the color of the point and beeps). When I click on the plots (weather is blue or red) nothing happens. I have used the exact code on a previous GUI (only with one axis) and it worked fine. The button down function is the same for all the axes. Here is my code: % --- Executes on mouse press over axes background. function axes1_ButtonDownFcn(hObject, eventdata, handles) % hObject handle to axes1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) cp = get(gca,'currentpoint') o = get(gco,'Color') beep x = cp(1,1); if o == [1 0 0] beep end; return Thank you for your help, Jean
From: Steven Lord on 19 May 2010 16:28 "Jean " <domnul_jan(a)yahoo.com> wrote in message news:ht1fdr$fcs$1(a)fred.mathworks.com... > Hello to all of you Matlab fans, > > I have a GUI composed of 3 axes, 2 buttons and a listbox. > > From the first button I load 3 signals and plot each of them them into an > axis. The second button plots in each axes a detection curve in red. > > When I click on the white background of the axes the program does what I > want (calculates the current point position, gives me the color of the > point and beeps). When I click on the plots (weather is blue or red) > nothing happens. I have used the exact code on a previous GUI (only with > one axis) and it worked fine. The button down function is the same for all > the axes. Here is my code: When you call PLOT, if the axes NextPlot property is set to 'replace' (which it is by default) most of the properties of the axes (including ButtonDownFcn) are reset to their default values. The documentation for the axes ButtonDownFcn property describes this: http://www.mathworks.com/access/helpdesk/help/techdoc/ref/axes_props.html#ButtonDownFcn Change the axes NextPlot property to 'replacechildren' to avoid this, or set the ButtonDownFcn after calling PLOT, or use the low-level LINE function instead of the higher-level PLOT function. Also note that if you click on a line or image on the axes, rather than the axes themselves, the ButtonDownFcn of the axes will not trigger unless those objects have their HitTest property set to 'off'. See the help for this property in the Handle Graphics Object Property Browser to which I linked above. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
From: Jean on 19 May 2010 17:05 Dear Steven, Thank you for your help. unfortunately I followed your advice and changed the HitTest property to "off", but then the function would not return the coordinates even when I press on the white background. The "replace children" problem had no effect. I have made a separate simple GUI with a button and an axis and I had the same problem. The thing is that I have another GUI made with 4 axes ,only one has it's buttondownfunction activated and it works perfect. I cannot use the "line" function because I am plotting signals. what should I do next? Best regards, Jean. "Steven Lord" <slord(a)mathworks.com> wrote in message <ht1hlb$ean$1(a)fred.mathworks.com>... > > "Jean " <domnul_jan(a)yahoo.com> wrote in message > news:ht1fdr$fcs$1(a)fred.mathworks.com... > > Hello to all of you Matlab fans, > > > > I have a GUI composed of 3 axes, 2 buttons and a listbox. > > > > From the first button I load 3 signals and plot each of them them into an > > axis. The second button plots in each axes a detection curve in red. > > > > When I click on the white background of the axes the program does what I > > want (calculates the current point position, gives me the color of the > > point and beeps). When I click on the plots (weather is blue or red) > > nothing happens. I have used the exact code on a previous GUI (only with > > one axis) and it worked fine. The button down function is the same for all > > the axes. Here is my code: > > When you call PLOT, if the axes NextPlot property is set to 'replace' (which > it is by default) most of the properties of the axes (including > ButtonDownFcn) are reset to their default values. The documentation for the > axes ButtonDownFcn property describes this: > > http://www.mathworks.com/access/helpdesk/help/techdoc/ref/axes_props.html#ButtonDownFcn > > Change the axes NextPlot property to 'replacechildren' to avoid this, or set > the ButtonDownFcn after calling PLOT, or use the low-level LINE function > instead of the higher-level PLOT function. > > Also note that if you click on a line or image on the axes, rather than the > axes themselves, the ButtonDownFcn of the axes will not trigger unless those > objects have their HitTest property set to 'off'. See the help for this > property in the Handle Graphics Object Property Browser to which I linked > above. > > -- > Steve Lord > slord(a)mathworks.com > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ > To contact Technical Support use the Contact Us link on > http://www.mathworks.com >
From: Matt Fig on 19 May 2010 17:52 plot(1:10) set(gca,'buttondownfcn','title(''Off the line'')') set(get(gca,'child'),'buttondownfcn','title(''On the line'')') Now try clicking and watch the title of the plot.
From: Jean on 19 May 2010 18:13
Hello Matt, Thank you for the message, but I need the coordinates and color of the point in the axes where I click. Your code works, but I cannot get my information. Best regards, Jean. "Matt Fig" <spamanon(a)yahoo.com> wrote in message <ht1mi5$ahe$1(a)fred.mathworks.com>... > plot(1:10) > set(gca,'buttondownfcn','title(''Off the line'')') > set(get(gca,'child'),'buttondownfcn','title(''On the line'')') > > Now try clicking and watch the title of the plot. |