How to remove dotted border from pushbutton created by uicontrol function?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello Sir, I am developing GUI in Matlab R2015b programmatically. I want to remove the dotted border around the pushbutton created using uicontrol function. The following message box is created by me using figure and uicontrol
Whenever I click on push button this dotted border will appear and I want to remove them.
4 commentaires
Réponses (1)
Jan
le 24 Déc 2015
The dotted line marks the GUI obejct, which has the current focus. This feature is controlled by the operating system and it belongs to the standard user interface. It appears also, when you use Tab to move the selection such that you know, which object is affected by pressing teh space key. Are you sure you want to remove it?
If you are sure that the user is not confused by changing the default behavior of the GUI elements, you can set the focus back to the current figure in the button's callback. This should be performed by figure(gcbf), but unfortuantely this command does not work as announced in the documentation since Matlab 5.0. (@MathWorks: Come on!)
As workaround you can call this function from the uicontrol 's callback:
function FocusToFig(ObjH, EventData) %#ok<INUSD>
% Move focus to parent figure
% FocusToFig(ObjH, [optionalUnsuedEventData])
% Tested: Matlab 6.5, 7.7, 7.8, 7.13, 8.6, WinXP/32, Win7/64
% Author: Jan Simon, Heidelberg, (C) 2009-2015
if any(ishandle(ObjH)) % Catch no handle and empty ObjH
FigH = ancestor(ObjH, 'figure');
% Work-around
if strcmpi(get(ObjH, 'Type'), 'uicontrol')
set(ObjH, 'Enable', 'off');
drawnow;
set(ObjH, 'Enable', 'on');
pause(0.02); % Give the re-enabled control a chance to be rendered
end
% Methods according to the documentation (does not move the focus for
% keyboard events under Matlab 5.3, 6.5, 2008b, 2009a, 2011b, 2015b):
figure(FigH);
set(0, 'CurrentFigure', FigH);
end
Please send a bug report to TMW concerning "figure(FigH)". I've done it too many times without success already. :-(
0 commentaires
Voir également
Catégories
En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!