How to remove dotted border from pushbutton created by uicontrol function?

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 Comments

It might be an operating system attribute. What operating system are you using?
You can tell from the window decorations that it must be one of the MS Windows.
This is not something that is happening to me in R2014a on OS-X: the edges of the border are incised (or is it "excised"?), the slightly 3 dimensional etched look.
Hello Walter, I am using the Microsoft Windows 7 professional.
Hello Walter, The border is removed automatically after deployment of application. This border is appear only when you are developing the application and run in matlab.

Sign in to comment.

Answers (1)

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. :-(

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Asked:

on 23 Dec 2015

Commented:

on 31 Dec 2015

Community Treasure Hunt

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

Start Hunting!