From f0f83adecfa0af8b65e606e065911e9467335841 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 18 Oct 2015 03:57:33 +0200 Subject: [PATCH] Create native buttons without any label in wxOSX/Cocoa Since the changes of db9baf9aa5565a7a4f92097b2f0c85439c35b4a6 the label wasn't explicitly reset to be empty on wxWindow creation because it was assumed it would already be empty if not explicitly set, but this turned out to be false for the controls using NSButton which (very helpfully) uses "Button" as its label by default and so kept this useless label if it wasn't explicitly overridden. Fix this by explicitly resetting the NSButton title after creating it, to ensure consistency between the real state of the control and what wxWidgets thinks it is. Closes #17152. (cherry picked from commit ef1db7acda601ec5dd6240094233938341fbd43e) --- src/osx/cocoa/button.mm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/osx/cocoa/button.mm b/src/osx/cocoa/button.mm index f38947d96f..94028be063 100644 --- a/src/osx/cocoa/button.mm +++ b/src/osx/cocoa/button.mm @@ -37,6 +37,18 @@ } } +- (id) initWithFrame:(NSRect) frame +{ + self = [super initWithFrame:frame]; + + // NSButton uses "Button" as its title by default which is inconvenient as + // wxWidgets expects the control to not have any default label, so reset it + // here to resolve this mismatch. + [self setTitle:@""]; + + return self; +} + - (int) intValue { switch ( [self state] )