How can I set the mouse pointer when hovering over a certain UICONTROL or UIPANEL in MATLAB 7.7 (R2008b)?
1 回表示 (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2011 年 6 月 13 日
編集済み: MathWorks Support Team
2017 年 9 月 14 日
I want my mouse pointer to change whenever it is over a specific UICONTROL or UIPANEL. I know I can set the 'Pointer' property for a whole figure, but I need to do this for only a specific control.
採用された回答
MathWorks Support Team
2017 年 9 月 14 日
There is a 'WindowButtonMotionFcn' for figures, if you combine this with some logic you can change the pointer when you are over a certain UIPANEL; see the following example:
function example1
% Create the figure and define the "MouseMove" Callback
f = figure('WindowButtonMotionFcn',@MoveCallback);
% Define where to place your UIPANEL
up.x = 50;
up.y = 150;
up.width = 100;
up.height = 200;
% Create the UIPANEL
up.handle = uipanel(f,'Units','Pixels','Position',[up.x up.y up.width up.height])
function MoveCallback(source, event)
% Get the current position of your mouse pointer
p = get(f,'CurrentPoint');
% Check if the mouse is currently over the UIPANEL
if (p(1) > up.x) && (p(1) < up.x + up.width) ...
&& (p(2) > up.y) && (p(2) < up.y + up.height)
% If so change the pointer
set(f,'Pointer','circle')
else
% Otherwise set/keep the default arrow pointer
set(f,'Pointer','arrow')
end
end
end
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Interactive Control and Callbacks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!