Reputation: 201
I am building a project in OSX (Yosemite) with wxWidgets 3.0.2.
I can remove a blue border around the wxTextCtrl window by using wxBORDER_NONE. But when I put it in a sizer, it has a 3 pixel grey border that I just can't get rid of. What's the point of having 2 borders, one of which cannot be removed? Surely people want to customise more than that?
Is there any possible way to remove it? I don't really want to hack at the wx source, but I will if I have to.
Or is there another way of controlling layout without using sizers, than might cause the border not to appear?
Update: It seems to be the focus highlight border. I don't want it.
Is there any way of disabling the border around the focused UI object? It's so frustrating because it is such a minor thing, but my program is useless if can't remove it.
Upvotes: 1
Views: 1280
Reputation: 246
This worked for me -on Windows-:
First --> bind the EVT_SET_FOCUS to a styling method.
Second --> reset the fg and bg colours to your original design.
Python code:
button_1.Bind(wx.EVT_SET_FOCUS, focus_without_border)
def focus_without_border(evt=None):
element = evt.GetEventObject()
element.SetForegroundColour( wx.Colour( 241, 241, 241 ) )
element.SetBackgroundColour( wx.Colour( 40, 41, 42 ) )
Upvotes: 0
Reputation: 29697
In case someone else stumbles into this post, this answer is for the updated question:
Update: It seems to be the focus highlight border. I don't want it.
Is there any way of disabling the border around the focused UI object?
Using wxWidgets APIs, NO, there is no way to remove it, since it's a behavior of the native NSTextField
class. I was only able to remove it by editing the wx source itself to set the focusRingType property of the underlying NSTextField
object to NSFocusRingTypeNone:
File: core/textctrl.mm
Func: wxWidgetImpl::CreateTextControl
NSTextField* v = nil;
if ( style & wxTE_PASSWORD )
v = [[wxNSSecureTextField alloc] initWithFrame:r];
else
v = [[wxNSTextField alloc] initWithFrame:r];
...
// remove glow/border when textfield gets focused
[v setFocusRingType:NSFocusRingTypeNone];
I've also set BORDER_NONE
on my wxTextCtrl
.
Of course, this sort of changes the standard OS X look-and-feel, so maybe that's why this wasn't exposed as a wxTextCtrl
API? Or it breaks something else? But so far it's working OK on my end. Plus, my app needs to have its own custom theme that doesn't go well with the glow border.
I'm using wxWidgets 3.1.0 (cloned from their repo) and OS X 10.12.
Upvotes: 1