Error while evaluating Axes ButtonDownFcn

6 ビュー (過去 30 日間)
Nikolaj Daniel
Nikolaj Daniel 2018 年 6 月 21 日
編集済み: Nikolaj Daniel 2018 年 6 月 21 日
Im trying to making a ButtonDownFcn for one of my axes in a gui created in GUIDE. But due to my lack of knowledge I dont know which input arguments to use.
Main Code:
function hgui = saxsgui(varargin)
xyChildren = get(gui.xy_axes,'Children');
rthChildren = get(gui.rth_axes,'Children');
xyChildren.HitTest = 'off';
rthChildren.HitTest = 'off';
gui.rth_axes.ButtonDownFcn = {@zoomon_click};
gui.xy_axes.ButtonDownFcn = {@zoomon_click};
%The function for ButtonDownFcn.
function zoomon_click(handles, gui) %hObject,
%callback for zoom shortcut
% handles = guidata(hObject);
menu = findobj('Label','Zoom');
menu = findobj(menu,'tag','MenuViewZoom');
% set(gui.zoomoff_button,'Visible','on')
state = 'on';
zoom(gui.figure, state)
togglemenu(menu)
% guidata(hObject,handles);
Error message:
No appropriate method, property, or field 'figure' for class 'matlab.graphics.eventdata.Hit'.
Error while evaluating Axes ButtonDownFcn
  3 件のコメント
Dennis
Dennis 2018 年 6 月 21 日
編集済み: Dennis 2018 年 6 月 21 日
is a callback function so your first 2 function inputs are passed by Matlab, namely hObject and event. Try to change it to
function zoomon_click(hObj,~,handles,gui)
It seems like you are using gui to pass handles instead of handles, maybe you can omit one of those.
edit: you need to change your callback to
{@zoomon_click,gui}
Nikolaj Daniel
Nikolaj Daniel 2018 年 6 月 21 日
編集済み: Nikolaj Daniel 2018 年 6 月 21 日
Thank you for the quick anwser... Im not able to try your sugestions right now but will do it later.
The part with saxsgui isen´t that important right now. I have skipped alot of coding so only what im working with right now is showned as i diden't knew if it was needed.
EDIT: It worked as a charm. Thank you Geoff and Dennis for your answers

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

回答 (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