Discussion:
[Foxgui-users] FXButton
Julia Dudascik (Contractor)
2016-09-22 21:10:36 UTC
Permalink
Hello

I have a FXButton in a toolbar. So it is a "toolbar" style button and has a
flat look.
When that button is pressed, I want the state to remain as "STATE_ENGAGED",
until it is pressed again. I am able to do this by creating a class that is
derived from FXButton.

The problem I have is that, while this button is in a "STATE_ENGAGED" mode,
I would like it to appear to be "pressed down" or have some indication that
the option is currently on.

I have tried to change the color of the button and even the style
(setButtonStyle) and the button look does not change. I call setButtonStyle
within the function that indicates the button has been pressed. No matter
what I do, the button still looks the same. I even call forceRefresh and
repaint().

How can I make the toolbar style button to appear "pressed-down" when this
option is on?

Thanks
Julia
JVZ
2016-09-22 21:41:46 UTC
Permalink
On Thu, 22 Sep 2016 17:10:36 -0400
Post by Julia Dudascik (Contractor)
Hello
I have a FXButton in a toolbar. So it is a "toolbar" style button and has a
flat look.
When that button is pressed, I want the state to remain as "STATE_ENGAGED",
until it is pressed again. I am able to do this by creating a class that is
derived from FXButton.
The problem I have is that, while this button is in a "STATE_ENGAGED" mode,
I would like it to appear to be "pressed down" or have some indication that
the option is currently on.
I have tried to change the color of the button and even the style
(setButtonStyle) and the button look does not change. I call setButtonStyle
within the function that indicates the button has been pressed. No matter
what I do, the button still looks the same. I even call forceRefresh and
repaint().
How can I make the toolbar style button to appear "pressed-down" when this
option is on?
If you use FXToggleButton, you can set two icons, a normal one and a
checked one.

With FXButton, I can show "checked" vs "unchecked" by implementing the
update handler; the update handler then sends ID_CHECK or ID_UNCHECK
message to the FXButton to check/uncheck its state.

For instance, in FXGLViewer I have code like:

// Update front-facing button if facing front
long FXGLViewer::onUpdFront(FXObject* sender,FXSelector,void*){
FXbool facingfront = (...are we facing front...);
sender->handle(this, facingfront ? FXSEL(SEL_COMMAND,ID_CHECK) : FXSEL(SEL_COMMAND,ID_UNCHECK),NULL);
return 1;
}

See attached image for how it looks....


-- JVZ





+----------------------------------------------------------------------------+
| Copyright (C) 16:30 09/22/2016 Jeroen van der Zijp. All Rights Reserved. |
+----------------------------------------------------------------------------+
Loading...