skip to Main Content

I have a dialog and at the bottom a normal box sizer with 3 buttons in it.
When I do

m_buttonCancel->SetDefault();

the code works in the sense that pressing enter does cancel, but there is no visual clue that this is the default button. I would like the button to have a rectangle around it, similar to when I say

m_buttonCancel->SetFocus();

Problem is: other widgets often have the focus, like wxTextCtrl widgets in the dialog. Then this focus border around the button disappears, but I would like it to stay.
Of course, I could put this button in a panel and set the border style, but then the size of this button would be different from the others or I must put these in separate panels also (but without border).

There must be an easier way to draw a border around a button, without changing the size of any button and without affecting the layout?

OS: CentOS, so wxWidgets uses Gtk.

2

Answers


  1. You have also to tell the dialog that button is a default item, depending on implementationOS, it’s handled differently

        SetDefaultItem(m_buttonCancel);
    

    Though I may say that it’s odd that you set Cancel as button which would react to Enter key, that’s usually OKs role, the ESC key is handled separately.

    Login or Signup to reply.
  2. Why don’t you just call both SetDefault() and SetFocus() on the button if this is what you want? Being "default" and being "focused" are different and neither one implies the other, so if you want both, just say so.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search