Fix wxButton::SetBitmap() to keep correct button style in OS X (PR #26025)

19 views
Skip to first unread message

RobertRoeb

unread,
Dec 10, 2025, 2:48:21 PM (2 days ago) Dec 10
to wx-...@googlegroups.com, Subscribed
  • Before, when setting a new bitmap (e.g. from Play bitmap to Pause bitmap) the button would be recreated in pure text button style, much too narrow.
  • Then secondly, when taking into account the bitmap, it switch from slightly rounded to unrounded corners. I assume that the initial look with slightly rounded corners was intented (and intended to be kept) and now it is preserved after setting a new bitmap

You can view, comment on, or merge this pull request online at:

  https://github.com/wxWidgets/wxWidgets/pull/26025

Commit Summary

  • 590b025 Fix wxButton::SetBitmap() to keep correct button style in OS X

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26025@github.com>

VZ

unread,
Dec 10, 2025, 5:17:06 PM (2 days ago) Dec 10
to wx-...@googlegroups.com, Subscribed

@vadz commented on this pull request.

Thanks, I didn't test this but from reading the code it looks like it should do the right thing. @csomor Do you have any objections to merging this?


In src/osx/cocoa/button.mm:

> @@ -93,8 +93,7 @@ - (NSControlSize)controlSize;
     // switch bezel style for plain pushbuttons
     if ( bitmap.IsOk() )
     {
-        if ([GetNSButton() bezelStyle] == NSRoundedBezelStyle)
-            [GetNSButton() setBezelStyle:NSRegularSquareBezelStyle];
+        [GetNSButton() setBezelStyle:NSRegularSquareBezelStyle];

Should we perhaps use SetBezelStyleFromBorderFlags() here too to ensure that the bezel is always set consistently?


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26025/review/3564722249@github.com>

Stefan Csomor

unread,
Dec 11, 2025, 2:49:23 AM (2 days ago) Dec 11
to wx-...@googlegroups.com, Subscribed
csomor left a comment (wxWidgets/wxWidgets#26025)

@RobertRoeb Thanks! I haven't fully understood the sequence yet, where would it be recreated with pure text, I thought that SetBitmap() would call the implementation's SetBitmap without first re-creating something. But since it happens to you, then I understand that unconditionally changing the style make sense. But I'd also prefer to call the common SetBezelStyleFromBorderFlags() to keep all our HIG wisdom at one place and consistent, would just calling this instead of manipulating the style directly also solve your problem ?

According to the docs NSRegularSquareBezelStyle and NSSmallSquareBezelStyle are perfect for bitmaps and other cases because they can scale to any size, while NSRoundedBezelStyle a.k.a NSBezelStylePush are for text content, so I think it's decision tree is still valid. Otherwise I'd prefer to fix it there.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26025/c3640670084@github.com>

Reply all
Reply to author
Forward
0 new messages