Underline text when mouse passes over it
8 views (last 30 days)
Show older comments
Hi,
I have a GUI with a table and 3 text strings that I will use as a button.
I want to underline that text string, that is an axes child, when i pass the mouse over it.
These are the buttons:
% Add button
set(handles.ax_bt_add, 'Visible','on','HandleVisibility','on',...
'Units','centimeters',...
'Position',[.5+tabDim(3)+.5,12,3,1],...
'color','none')
text(handles.ax_bt_add,0.1,0.5, 'Add','FontSize', 14,...
'Units','norm',...
'HorizontalAlignment','left',...
'VerticalAlignment', 'middle' )
handles.ax_bt_add.XAxis.Visible = 'off';
handles.ax_bt_add.YAxis.Visible = 'off';
% Edit button
set(handles.ax_bt_edit, 'Visible','on','HandleVisibility','on',...
'Units','centimeters',...
'Position',[.5+tabDim(3)+.5,10.5,3,1],...
'color','none' )
text(handles.ax_bt_edit,0.1,0.5, 'Edit','FontSize', 14,...
'Units','norm',...
'HorizontalAlignment','left',...
'VerticalAlignment', 'middle' )
handles.ax_bt_edit.XAxis.Visible = 'off';
handles.ax_bt_edit.YAxis.Visible = 'off';
% Delete button
set(handles.ax_bt_delete, 'Visible','on','HandleVisibility','on',...
'Units','centimeters',...
'Position',[.5+tabDim(3)+.5,9,3,1],...
'color','none' )
text(handles.ax_bt_delete,0.1,0.5, 'Delete','FontSize', 14,...
'Units','norm',...
'HorizontalAlignment','left',...
'VerticalAlignment', 'middle' )
handles.ax_bt_delete.XAxis.Visible = 'off';
handles.ax_bt_delete.YAxis.Visible = 'off';
Then, I saw a way to know when mouse is over that text, here in the forum. It works perfectly. But now I want to know how to underline it.
function mat_fig_WindowButtonMotionFcn(hObject, eventdata, handles)
% hObject handle to mat_fig (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% get the current position of the mouse
mousePos = get(hObject,'CurrentPoint');
mouseX = mousePos(1);
mouseY = mousePos(2);
hChildren = get(hObject,'Children');
for k=1:length(hChildren)
hUiControl = hChildren(k);
% get the child position
uiControlPos = get(hUiControl,'Position');
% create the x and y lower (L) and upper (U) bounds
uiControlXL = uiControlPos(1);
uiControlXU = (uiControlPos(1)+uiControlPos(3));
uiControlYL = uiControlPos(2);
uiControlYU = (uiControlPos(2)+uiControlPos(4));
% check to see if the mouse is over the control
if mouseX>=uiControlXL && mouseX<=uiControlXU && ...
mouseY>=uiControlYL && mouseY<=uiControlYU
hTag=get(hUiControl,'tag');
if ~strcmp(hTag,'tab_mat') %this is just to ignore the table
axTxt=get(hUiControl,'Children')
set(axTxt(1),??????) %<------------------What should I put here???<---------------------
end
end
end
What would be the ??????
0 Comments
Answers (1)
See Also
Categories
Find more on Function Creation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!