Axis Button Down Function (Image / Axis)

19 ビュー (過去 30 日間)
Jasjit Janda
Jasjit Janda 2017 年 4 月 16 日
編集済み: Jasjit Janda 2017 年 9 月 22 日
I'm trying to make an axis (that I have put a image on) to trigger the button down function, and it doesnt want to work with the image on it. I have tried to adjust pickableparts and hittest, but nothing works.
function board_OpeningFcn(hObject, eventdata, handles, varargin)
board = imshow('resources/board.png');
board.HitTest = 'off';
board.PickableParts = 'none';
axes4.PickableParts = 'all';
handles.output = hObject;
guidata(hObject, handles);
....
function axes4_ButtonDownFcn(hObject, eventdata, handles)
disp('At line 95');
function axes4_CreateFcn(hObject, eventdata, handles)
The ButtonDownFcn still, only works without the image, the image still conflicts with the axis even though I turned off HitTest and PickableParts for the image in the OpeningFcn for the GUI.

採用された回答

Walter Roberson
Walter Roberson 2017 年 4 月 16 日
When you do the imshow() into the axes, the ButtonDownFcn attached to the axes is probably being removed. If you were to "hold on" the axes it might stay. The safest thing to do is put it back into place once the image is there:
ax4b = get(handles.axes4, 'ButtonDownFcn');
board = imshow('resources/board.png', 'Parent', handles.axes4);
set(handles.axes4, 'ButtonDownFcn', ax4b);
  1 件のコメント
Jasjit Janda
Jasjit Janda 2017 年 4 月 16 日
Yes, your right. Thank you. I went back in debugging mode to check if it actually clears the buttondownfcn when I do imshow and it does. Adding "hold on;" before adding the image worked.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeBlue についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by