Appearance of disabled elements

Questions, tips and tricks and techniques for scripting in Servoy

Appearance of disabled elements

Postby Robert Huber » Mon May 23, 2011 12:42 pm

Hi

We disable forms elements like buttons with the statement: elements.btnInsert.enabled = false;

Visually this appears like the first screenshot – hard to see what element it is when it's not grayed out, and visually not very appealing

I would prefer to have the visual appearance something like the second screenshot, clearly to read and visually appealing

Is this currently possible with Servoy 5.2.7, i. e. is there another command leading to the desired result?

Regards,
Attachments
current gray appearance with xy.enabled = false.png
current gray appearance with xy.enabled = false.png (5.16 KiB) Viewed 5931 times
prefered gray appearance.png
prefered gray appearance.png (4.97 KiB) Viewed 5931 times
Robert Huber
7r gmbh, Switzerland
SAN Developer
www.seven-r.ch
User avatar
Robert Huber
 
Posts: 1239
Joined: Tue Aug 23, 2005 6:52 pm
Location: Schaffhausen, Switzerland

Re: Appearance of disabled elements

Postby jcompagner » Mon May 23, 2011 2:42 pm

maybe you can tweak the ui defaults, here is a list:

http://www.duncanjauncey.com/java/ui/ui ... _OS_X.html

see also servoy camp: http://www.servoycamp.com/topics/tips/1 ... -feel.html
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Appearance of disabled elements

Postby Robert Huber » Tue May 24, 2011 8:15 pm

Do you know the file location of the look and feel file to be tweaked?

jcompagner wrote:maybe you can tweak the ui defaults, here is a list:

http://www.duncanjauncey.com/java/ui/ui ... _OS_X.html

see also servoy camp: http://www.servoycamp.com/topics/tips/1 ... -feel.html
Robert Huber
7r gmbh, Switzerland
SAN Developer
www.seven-r.ch
User avatar
Robert Huber
 
Posts: 1239
Joined: Tue Aug 23, 2005 6:52 pm
Location: Schaffhausen, Switzerland

Re: Appearance of disabled elements

Postby Harjo » Tue May 24, 2011 9:17 pm

Robert, what Johan, means is, that you can override, certain L&F behaviour right from Servoy.

Did you read the article??

We for instance, don't like the comboboxes when they, are disabled, so we override this on our onSolutionOpen method
Code: Select all
   application.setUIProperty("ComboBox.disabledBackground", new Packages.javax.swing.plaf.ColorUIResource(java.awt.Color.WHITE));
   application.setUIProperty("ComboBox.disabledForeground", new Packages.javax.swing.plaf.ColorUIResource(java.awt.Color.BLACK));
   

So in your case, you have to search in that list, Johan, gave you, for something that set's the disabledForeground, for a label or button

I see: Button.disabledText
or
Label.disabledForeground

so play with that a little bit, and see what works....
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: Appearance of disabled elements

Postby Robert Huber » Thu May 26, 2011 5:43 pm

Ah, thanks now I undestand!

I tried to set an RGB value instead of ... java.awt.Color.BLACK, something like
application.setUIProperty("Button.foreground", new Packages.javax.swing.plaf.ColorUIResource.getColor([r = 40, g = 30, b = 0]));

I tried various forms of the syntax, but none was correct.

Any idea?

Regards,
Robert Huber
7r gmbh, Switzerland
SAN Developer
www.seven-r.ch
User avatar
Robert Huber
 
Posts: 1239
Joined: Tue Aug 23, 2005 6:52 pm
Location: Schaffhausen, Switzerland

Re: Appearance of disabled elements

Postby jcompagner » Thu May 26, 2011 6:12 pm

new Packages.javax.swing.plaf.ColorUIResource(10,20,30)

something like that could work
Problem is that that constructor has integers and floats. So it could be that you have to do

new Packages.javax.swing.plaf.ColorUIResource(0.1,0.2,0.3);

where the 0.1 is used as 0.1*255=25 so R =25
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Appearance of disabled elements

Postby Robert Huber » Sat May 28, 2011 12:46 pm

Thanks Johan

The solution is your 2nd attempt for all others interested in this. So, for example the following makes the button font color a certain orange:

application.setUIProperty("Button.foreground", new Packages.javax.swing.plaf.ColorUIResource(0.969,0.286,0.008)); // Button font color r:247, b:73, g:2 (0.969 * 255, 0.286 * 255, 0.008 * 255)

This is for demo purposes, not that I am saying this color is a good idea - it's not .-)

Regards,

jcompagner wrote:new Packages.javax.swing.plaf.ColorUIResource(10,20,30)

something like that could work
Problem is that that constructor has integers and floats. So it could be that you have to do

new Packages.javax.swing.plaf.ColorUIResource(0.1,0.2,0.3);

where the 0.1 is used as 0.1*255=25 so R =25
Robert Huber
7r gmbh, Switzerland
SAN Developer
www.seven-r.ch
User avatar
Robert Huber
 
Posts: 1239
Joined: Tue Aug 23, 2005 6:52 pm
Location: Schaffhausen, Switzerland

Re: Appearance of disabled elements

Postby Harjo » Sat May 28, 2011 1:58 pm

Keep it simple! var vBackgroundcolor = new Packages.javax.swing.plaf.ColorUIResource(Packages.java.awt.Color.decode('#8492a5'))

:-)
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: Appearance of disabled elements

Postby Robert Huber » Sat May 28, 2011 2:18 pm

I try hard to keep it simple :-) but doesn't always work in the first attempt ;-)

I still didn't find a way to change the color (by default L&F dark grey) of a disabled button having an image media (attached). If you have an idea, I would be very pleased :-)

Regards,

Harjo wrote:Keep it simple! var vBackgroundcolor = new Packages.javax.swing.plaf.ColorUIResource(Packages.java.awt.Color.decode('#8492a5'))

:-)
Robert Huber
7r gmbh, Switzerland
SAN Developer
www.seven-r.ch
User avatar
Robert Huber
 
Posts: 1239
Joined: Tue Aug 23, 2005 6:52 pm
Location: Schaffhausen, Switzerland

Re: Appearance of disabled elements

Postby Harjo » Sat May 28, 2011 4:59 pm

oke, is it a button? or a label??

have you tried setting:

Code: Select all
Label.background   CColorPaintUIResource   Color[238,238,238]   #EEEEEE
Label.disabledForeground   ColorUIResource   Color[128,128,128]   #808080
Label.disabledShadow   ColorUIResource   Color[64,64,64]   #404040
Label.font   DerivedUIResourceFont   Font[family=Lucida Grande,name=Lucida Grande,style=0,size=13]   
Label.foreground   ColorUIResource   Color[0,0,0]
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: Appearance of disabled elements

Postby Robert Huber » Thu Jun 02, 2011 2:10 pm

Harjo wrote:oke, is it a button? or a label??


It's a button.

Harjo wrote:have you tried setting:

Code: Select all
Label.background   CColorPaintUIResource   Color[238,238,238]   #EEEEEE
Label.disabledForeground   ColorUIResource   Color[128,128,128]   #808080
Label.disabledShadow   ColorUIResource   Color[64,64,64]   #404040
Label.font   DerivedUIResourceFont   Font[family=Lucida Grande,name=Lucida Grande,style=0,size=13]   
Label.foreground   ColorUIResource   Color[0,0,0]


For example, the following command is setting the font color of buttons like the ones in the login dialog, but does NOT set the font color of Servoy buttons

Code: Select all
application.setUIProperty('Button.foreground', new Packages.javax.swing.plaf.ColorUIResource(java.awt.Color.decode('#004fcb'))); // Button font color


On the other hand, this command sets the background of a Servoy button (without an imageMedia attached)

Code: Select all
application.setUIProperty('Button.background', new Packages.javax.swing.plaf.ColorUIResource(java.awt.Color.decode('#e0a467'))); // Button background color


But if I have a button with a imageMedia, and it's disabled with

Code: Select all
elements.btnInsert.enabled = false;


then the button gets a dark grey. How can I change the color of THIS button, i. e. the color of the imageMedia, I assume?
The above commands don't work on Servoy buttons when a imageMedia is attached!
Any idea how to control buttons with imageMedia attached?

Regards
Robert Huber
7r gmbh, Switzerland
SAN Developer
www.seven-r.ch
User avatar
Robert Huber
 
Posts: 1239
Joined: Tue Aug 23, 2005 6:52 pm
Location: Schaffhausen, Switzerland


Return to Methods

Who is online

Users browsing this forum: No registered users and 4 guests

cron