Hot Topic (More than 10 Replies) [Solved] Highlighting active field (Read 1434 times)
Amor
Full Member
Members
***
Offline


No personal text

Posts: 366
Location: Germany
Joined: Feb 7th, 2004
[Solved] Highlighting active field
Dec 14th, 2007 at 4:39pm
Print Post Print Post  
Hello!
I want to know if there is a elegante possibility with sesame 2.04 to change  the color of the field background on element entry & exit.

Thanks.

Dr. Belhareth
« Last Edit: Dec 18th, 2007 at 1:13am by Hammer »  

Dr. med. Amor Belhareth&&Medizin Labor &&Germany
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Highlighting active field
Reply #1 - Dec 14th, 2007 at 4:45pm
Print Post Print Post  
A particular element, or any element you happen to enter/exit?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: Highlighting active field
Reply #2 - Dec 14th, 2007 at 8:25pm
Print Post Print Post  
Amor

Take a look at the commands
@Attribute()
Attribute()
Thiselement()
Clientlocalvalue

Set a clientlocalvalue to the color that the element background  is when you enter the element. Use @attribute command to get the background color of the attribute when you enter the element

Use the attribute command to set the color you want the element background or text to be.
.
Then on exit reset the attribute to the original color.

The Thiselement command will allow you to turn your code into a subroutine and use it wherever you like.

I have not done this so I could be off base.. but I hope this will get you closer to your goal, Hopefully the Lanticans will let us know if I am in left field.

Keep us posted on your progress.
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: Highlighting active field
Reply #3 - Dec 14th, 2007 at 9:16pm
Print Post Print Post  
if your element background colors are always the same this will work


#include "sbasic_include.sbas" // make sure you have this file in your default directory and that this line is in global code

// on entry code


     Attribute(ThisElement, ATTR_ID_BACK_RGB_COLOR, "0 200 255") //this color is aqua marine
     ForceRedraw()

//on Exit


Attribute(ThisElement, ATTR_ID_BACK_RGB_COLOR, "255 255 255") //this  should be set to your default background color.
     ForceRedraw()

These should be turned into subroutines and placed in global code

If you have varying background colors  you will need somthing more like this

//on entry
#include "sbasic_include.sbas" // make sure you have this file in your default directory and that this line is in global code

var vMyElementbkcolor as string


vMyElementbkcolor = @Attribute(Thiselement, ATTR_ID_BACK_RGB_COLOR)
writeln(vMyElementbkcolor)
clientLocalvalue("origBkcolor", vMyElementbkcolor)


     Attribute(ThisElement, ATTR_ID_BACK_RGB_COLOR, "0 200 255")
     ForceRedraw()

//on exit


Attribute(ThisElement, ATTR_ID_BACK_RGB_COLOR, @clientLocalvalue("cusidnum"))
     ForceRedraw()

  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Highlighting active field
Reply #4 - Dec 14th, 2007 at 9:24pm
Print Post Print Post  
@Robert: Check out PushAttribute and PopAttribute. They are built to do what you are doing with your ClientLocalValue.

@Amor: If you want to do this for all your elements, let me know. I can give you a way using @TriggeringElement to drop your code into Form::On Element Entry and Form::On Element Exit instead of having to put a subroutine call in each element individually.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: Highlighting active field
Reply #5 - Dec 14th, 2007 at 9:33pm
Print Post Print Post  
[quote author=Hammer link=1197650343/0#4 date=1197667468]@Robert: Check out PushAttribute and PopAttribute. They are built to do what you are doing with your ClientLocalValue. [/quote]

Will do! Thanks for the tip  :)
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Amor
Full Member
Members
***
Offline


No personal text

Posts: 366
Location: Germany
Joined: Feb 7th, 2004
Re: Highlighting active field
Reply #6 - Dec 17th, 2007 at 9:45am
Print Post Print Post  
Robert: Thanks for all this keen concept!
Erika: Your Inspiration is great, certainly  I would like this fonctionality for all of my elements.
Lanticans: Thank you for all the exiting new futures in sesame 2.0 ...


Thanks.
Dr. Belhareth
  

Dr. med. Amor Belhareth&&Medizin Labor &&Germany
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Highlighting active field
Reply #7 - Dec 17th, 2007 at 2:33pm
Print Post Print Post  
Sesame 2.0 includes a new command called @TriggeringElement. This can be used in Form events to return the name of the element that caused the Form event to run. You can use this in combination with ThisElement to create code that runs consistently for each element on your form.

For your case, Amor, you want all your elements to change and restore their background color as you move through the form, highlighting the current element.

GLOBAL CODE
[code]#include "sbasic_include.sbas"[/code]

Form::OnElementEntry
[code]var vElement as String

     vElement = @TriggeringElement()
     SetThisElement(vElement)
     PushAttribute(ThisElement, ATTR_ID_BACK_RGB_COLOR)
     Attribute(ThisElement, ATTR_ID_BACK_RGB_COLOR, "255 255 0")
     UnsetThisElement()
     ForceRedraw()
[/code]

Form::OnElementExit
[code]var vElement as String

     vElement = @TriggeringElement()
     SetThisElement(vElement)
     PopAttribute(ThisElement, ATTR_ID_BACK_RGB_COLOR)
     UnsetThisElement()
     ForceRedraw()
[/code]
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Amor
Full Member
Members
***
Offline


No personal text

Posts: 366
Location: Germany
Joined: Feb 7th, 2004
Re: [Solved] Highlighting active field
Reply #8 - Dec 19th, 2007 at 12:49pm
Print Post Print Post  
Hello Erika,

thanks for the perfect support.  Your  example-code works perfectly.

Dr. Belhareth
  

Dr. med. Amor Belhareth&&Medizin Labor &&Germany
Back to top
 
IP Logged
 
Amor
Full Member
Members
***
Offline


No personal text

Posts: 366
Location: Germany
Joined: Feb 7th, 2004
Re: [Solved] Highlighting active field
Reply #9 - Mar 3rd, 2008 at 2:42pm
Print Post Print Post  
Hello Erika,

how to use this routine only to affect the editable fileds?

Thanks.
  

Dr. med. Amor Belhareth&&Medizin Labor &&Germany
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: [Solved] Highlighting active field
Reply #10 - Mar 3rd, 2008 at 3:28pm
Print Post Print Post  
Quote:
Hello Erika,

how to use this routine only to affect the editable fileds?

Thanks.


What do you mean by "editable"? Do you mean not read-only, or that you only want to affect text boxes?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Amor
Full Member
Members
***
Offline


No personal text

Posts: 366
Location: Germany
Joined: Feb 7th, 2004
Re: [Solved] Highlighting active field
Reply #11 - Mar 3rd, 2008 at 9:30pm
Print Post Print Post  
Erika-

Yes, i  mean only the not read-only  text boxes?

Thanks.
  

Dr. med. Amor Belhareth&&Medizin Labor &&Germany
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: [Solved] Highlighting active field
Reply #12 - Mar 3rd, 2008 at 9:51pm
Print Post Print Post  
OK, here's the same code, but I've added a check for element type.

GLOBAL CODE
[code]#include "sbasic_include.sbas"[/code]

Form::OnElementEntry
[code]var vElement as String

     vElement = @TriggeringElement()
     SetThisElement(vElement)
     If (@ElementType(ThisElement) > 999) And (@ElementType(ThisElement) < 1009)
     {
               PushAttribute(ThisElement, ATTR_ID_BACK_RGB_COLOR)
             Attribute(ThisElement, ATTR_ID_BACK_RGB_COLOR, "255 255 0")
     }
     UnsetThisElement()
     ForceRedraw()
[/code]

Form::OnElementExit
[code]var vElement as String

     vElement = @TriggeringElement()
     SetThisElement(vElement)
     If (@ElementType(ThisElement) > 999) And (@ElementType(ThisElement) < 1009)
     {
             PopAttribute(ThisElement, ATTR_ID_BACK_RGB_COLOR)
     }
     UnsetThisElement()
     ForceRedraw()
[/code]
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Amor
Full Member
Members
***
Offline


No personal text

Posts: 366
Location: Germany
Joined: Feb 7th, 2004
Re: [Solved] Highlighting active field
Reply #13 - Mar 3rd, 2008 at 11:53pm
Print Post Print Post  
Erika, 

thanks again! 

Dr. Belhareth
  

Dr. med. Amor Belhareth&&Medizin Labor &&Germany
Back to top
 
IP Logged