필터 지우기
필터 지우기

App designer: UIAxis ButtonDownFcn with key modifier?

조회 수: 42 (최근 30일)
Neuropragmatist
Neuropragmatist 2023년 5월 1일
댓글: Neuropragmatist 2023년 5월 6일
Hi all,
I am using the app designer to design a small program, part of this involves getting the user to click on an axis. I use a ButtonDownFcn callback to get the location of the user's mouse click. I use this to select something plotted in the axis, that all works fine.
However, I would like to detect when the mouse click is associated with a modifier key press, such as ctrl or shift, so that the user can click on multiple items. I haven't found a way to do this.
There is the KeyPressFcn, but I'm not sure if this can be combined with the ButtonDownFcn? The UIAxis also stores a CurrentCharacter value, but this only tells me the last key pressed when the axis was selected, not that the current mouse click was simultaneous with a mouse click.
Does anyone have any ideas?

답변 (2개)

Walter Roberson
Walter Roberson 2023년 5월 1일
It isn't pretty... but if you set pickable parts false on your graphic objects but leave it true on your figure, then you can use a figure or uifigure button down function callback, in which case you can refer to the SelectionType property
You will probably want to test whether the CurrentPoint is inside a particular axes. For traditional figures there is an undocumented function https://undocumentedmatlab.com/matlab/wp-content/cache/all/articles/undocumented-mouse-pointer-functions/index.html . I do not know if it is available for uifigure
  댓글 수: 1
Neuropragmatist
Neuropragmatist 2023년 5월 6일
Thank you for the answer, I've been set back a little in this project but I hope to test what you have suggested soon and will get back/accept answers then!

댓글을 달려면 로그인하십시오.


Simon Chan
Simon Chan 2023년 5월 1일
You may combine several callbacks to achieve your goal.
The attached example uses WIndowKeyPressFcn and WindowReleaseFcn from a uifigure, with a combination of ButtonDownFcn on a primitive line.
With the 'control' or 'shift' key pressed, it display the x- or y-values of the clicked points respectively. On the other hand, you can configure it to do something else when no key is pressed with mouse click.
  댓글 수: 1
Neuropragmatist
Neuropragmatist 2023년 5월 6일
Thank you for the answer, I've been set back a little in this project but I hope to test what you have suggested soon and will get back/accept answers then!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Develop uifigure-Based Apps에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by