Hello,
We have request for button style behaviour:
Inactive (dissabled) buttons should have fill color grey
Enabled buttons should fill red. All others states (i.e. focused, mouseover etc.) are identified by text style change and cursor for mouseover, the fill reminds red.
The problem is, in Theme definition, for pushButton style are available Mouseoverstyle, Focusedinactivestyle Selectedinactivestyle Selectedstyle and Focusedstyle
Therefore, all active changes are not problem, but we cannot find how to differ the color of Enabled/Dissabled button, which is not focused, not selected, not mouse placed. Can you advice how to set the theme for it?
Theme for required button style
Re: Theme for required button style
Hi Jiri,
You may have to create a custom theme draw style for the enabled/disabled states. Then manually set the button's themedrawstyle when you enable or disable the button.
This may get a bit messy as I don't think themes are additive, meaning you can not add multiple drawstyles to a single control. So the custom draw style may have to all the style elements for a particular state.
You may have to create a custom theme draw style for the enabled/disabled states. Then manually set the button's themedrawstyle when you enable or disable the button.
Code: Select all
if (#Button3.Enabled)
#Button3.Enabled := False
#Button3.ThemeDrawStyle := ButtonDisabled
else
#Button3.Enabled := True
#Button3.ThemeDrawStyle := ButtonEnabled
endif
endroutine
- Stewart Marshall
- Posts: 417
- Joined: Thu Nov 05, 2015 5:25 pm
Re: Theme for required button style
Hi Jiri
Currently, Theme's don't provide a way of specifying a disabled appearance, so you'll need to make a Disabled DrawStyle and apply it at runtime.
Fortunately, when defining a DrawStyle for a Disabled state, you need only specify the Style. The control will be disabled, so MouseOver, Focus and Selection become irrelevant.
If you change the PushButton DrawStyle itself to the colours you require, that will be applied automatically to all buttons, so Joe's sample code becomes as follows.
One important thing to note is that DrawStyles are cumulative. This can be done on the ribbon by holding down the Ctrl key, or by setting in code.
Only the features specifically coded in the Styles that make up a DrawStyle will be overriden. All other Style settings will remain exactly as is.
So in Joe's sample code where he's used a specific DrawStyle on a Button, you could write the following
ButtonDisabled need only define the Fill colour. All other features of ButtonEnabled would remain unchanged.
Regards
Currently, Theme's don't provide a way of specifying a disabled appearance, so you'll need to make a Disabled DrawStyle and apply it at runtime.
Fortunately, when defining a DrawStyle for a Disabled state, you need only specify the Style. The control will be disabled, so MouseOver, Focus and Selection become irrelevant.
If you change the PushButton DrawStyle itself to the colours you require, that will be applied automatically to all buttons, so Joe's sample code becomes as follows.
Code: Select all
if (#Button3.Enabled)
#Button3.Enabled := False
#Button3.ThemeDrawStyle := ButtonDisabled
else
#Button3.Enabled := True
#Button3.ThemeDrawStyle := ""
endif
endroutine
Code: Select all
#Control.ThemeDrawStyle := DrawStyle1+DrawStyle2
So in Joe's sample code where he's used a specific DrawStyle on a Button, you could write the following
Code: Select all
if (#Button3.Enabled)
#Button3.Enabled := False
#Button3.ThemeDrawStyle := ButtonEnabled+ButtonDisabled
else
#Button3.Enabled := True
#Button3.ThemeDrawStyle := ButtonEnabled
endif
endroutine
Regards
Re: Theme for required button style
I did not know you could do that with DrawStyles.
Good to know!
Good to know!