600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > matlab中上下光标的作用 当鼠标移动到按钮上时改变光标形状

matlab中上下光标的作用 当鼠标移动到按钮上时改变光标形状

时间:2020-03-23 21:12:36

相关推荐

matlab中上下光标的作用 当鼠标移动到按钮上时改变光标形状

最近在做一个东西的时候,发现需要采用一下在VC编程中惯用的技术,就是当鼠标移动到按钮等控件时,将光标改变为指定的形状,如小手等,在本论坛上我找到了一篇文章,其链接为/redirect.php?fid=9&tid=67093&goto=nextnewset&sid=CnFzl1,该文的楼主的问题其实并没有得到完整的解决,我做了一下尝试,发现是可以实现的,现将代码奉献于下,高手请跳过。

主要代码部分如下:

% --- Executes on mouse motion over figure - except title and menu.

function figure_test_change_to_hand_WindowButtonMotionFcn(hObject, eventdata, handles)

% hObject handle to figure_test_change_to_hand (see GCBO)

% eventdatareserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

position_first = get(handles.push_the_first, 'Position');

position_second = get(handles.push_the_second, 'Position');

position_third = get(handles.push_the_third, 'Position');

current_point = get(handles.figure_test_change_to_hand, 'currentpoint');

if (((current_point(1) >= position_first(1)) && (current_point(1) <= (position_first(1) + position_first(3)))) && ...

((current_point(2) >= position_first(2)) && (current_point(2) <= (position_first(2) + position_first(4))))) || ...

(((current_point(1) >= position_second(1)) && (current_point(1) <= (position_second(1) + position_second(3)))) && ...

((current_point(2) >= position_second(2)) && (current_point(2) <= (position_second(2) + position_second(4))))) || ...

(((current_point(1) >= position_third(1)) && (current_point(1) <= (position_third(1) + position_third(3)))) && ...

((current_point(2) >= position_third(2)) && (current_point(2) <= (position_third(2) + position_third(4)))))

set(handles.figure_test_change_to_hand, 'Pointer', 'hand');

else

set(handles.figure_test_change_to_hand, 'Pointer', 'arrow');

end

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。