Hot Topic (More than 10 Replies) Element color changes in Table View (Read 2512 times)
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Element color changes in Table View
Jul 12th, 2013 at 1:08pm
Print Post Print Post  
I have an application that changes the color of an element depending on the value of a second element.  When the CLOSED element is set to "Y", the DESCRIPTION element background changes to brown.  When CLOSED is set to "N", the DESCRIPTION element background is while.

I just noticed that when I look at a group of records that should have different background colors in Table View, the background colors of all the DESCRIPTION elements is the same as the record that was active at the time I switched to Table View.

Is this behavior inherent in Table View, or is there something I can program so the background colors will remain the proper color in Table View?
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Element color changes in Table View
Reply #1 - Jul 12th, 2013 at 1:54pm
Print Post Print Post  
Hello,

You will want to put your color changing programming into the DESCRIPTION :: On Draw event, this will cause it to run for each record in Table view setting the color of that cell in each row as the Table is created.

Note: Do not put ForceRedraw() in there or it can get stuck in a loop because the Draw event is causing another Draw event which is causing another, well you get the picture.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: Element color changes in Table View
Reply #2 - Jul 15th, 2013 at 8:17pm
Print Post Print Post  
Ray, I tried your suggestion and got some really weird results.  The screen would lock up with a double image whenever I tried to go to table view.  I then tried rem'ing out the programming and put a simple writeln statement in its place.  When i did that, I got the writeln window as soon as I opened the file. 

When the writeln window opened, I got two statements (even though my writeln command only had one statement, i would get duplicates).  And every time I clicked on the screen I got two more statements and I couldn't get to the application screen.

Here's the programming I was using:

/*
If IssueClosed ="N"
{
     RGBColor(IssueClosed, 0, 0, 0, 107,255,99)
     RGBColor(BasicDescription, 0,0,0,255,255,255)
}
Else
{
     If IssueClosed ="Y"
     {
           RGBColor(IssueClosed, 0, 0, 0, 226,145,145)
           RGBColor(BasicDescription, 0, 0, 0, 226,145,145)
     }
     Else
     {
           If @IsBlank(IssueClosed)
           {
                 RGBColor(IssueClosed, 0, 0, 0, 255,255,255)
           }
           
     }
}
                       


*/


writeln("Made it here!")

Any thoughts?
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Element color changes in Table View
Reply #3 - Jul 16th, 2013 at 4:37pm
Print Post Print Post  
Hello Paul,

The writeln() running twice does not surprise me as it is likely triggering the draw again when it runs the first time.

How many records did you have retrieved when you tried to open up Table view with the original programming? Remember that since it runs for each record in the table view, it can take a little while. The other thought is that there is some other piece of programming that is conflicting with it.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: Element color changes in Table View
Reply #4 - Jul 17th, 2013 at 3:05pm
Print Post Print Post  
It was invoking the command as soon as I opened the Retrieve Spec.  I was able to get beyond that by adding an IF statement so the ON DRAW command would only work is @MODE()=1.

I then selected only 1 record but the programming would invoke immediately upon retrieving the record and then any time I clicked the mouse anywhere on the screen!  The only programming I had was a writeln() statement.

Not sure where to go from here....
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Element color changes in Table View
Reply #5 - Jul 17th, 2013 at 4:59pm
Print Post Print Post  
The On Draw event will be invoked very frequently. It gets called whenever that element gets redrawn. For example, if you obscure an element by dragging another window in front of it and then reveal it, the redraw must happen many times as the element is gradually revealed. Tables are particular sensitive to redraws.

Never put anything in an On Draw event that does not affect the element itself. So, writeln, which affects the slate window, is very likely to cause problems.  Also, in general, make sure any code in an On Draw event is very efficient and fast.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: Element color changes in Table View
Reply #6 - Jul 17th, 2013 at 5:43pm
Print Post Print Post  
I've got is kinda working.  I have a few lines of programming that are invoked in the ON DRAW area.  Everything seems to be working OK except when I go to TABLE view.  The screen seems to "double" (see attached; note the top of the picture). 

If I click on a tab at the bottom of the Sesame application and then come back to this one, the table is now visible!

Is my programming interfering with the table view action?  Here's the programming:


If IssueClosed ="N"
{

     RGBColor(BasicDescription, 0,0,0,255,255,255)
}
Else
{
     If IssueClosed ="Y"
     {
           RGBColor(BasicDescription, 0, 0, 0, 226,145,145)
     }
     Else
     {
           If @IsBlank(IssueClosed)
           {
                 RGBColor(IssueClosed, 0, 0, 0, 255,255,255)
           }
           
     }
}
     

Let me know what you think.

Thanks!
                 
  

pnc1.png ( 62 KB | 42 Downloads )
pnc1.png
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Element color changes in Table View
Reply #7 - Jul 17th, 2013 at 6:30pm
Print Post Print Post  
In your code, I see you affecting more than one element:
Code
Select All
f IssueClosed ="N"
{

     RGBColor(BasicDescription, 0,0,0,255,255,255)
}
Else
{
     If IssueClosed ="Y"
     {
           RGBColor(BasicDescription, 0, 0, 0, 226,145,145)
     }
     Else
     {
           If @IsBlank(IssueClosed)
           {
                 RGBColor(IssueClosed, 0, 0, 0, 255,255,255)
           }

     }
}
 



You should only affect the element that has the On Draw event. So you need to have code in the IssueClosed On Draw event and in the BasicDescription On Draw event. Neither should change the other.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: Element color changes in Table View
Reply #8 - Jul 22nd, 2013 at 12:50pm
Print Post Print Post  
I reduced the programming to make it as simple as possible, however the color status of BASIC DESCRIPTION depends on the value in ISSUECLOSED. 

Are you saying that the On Draw event won't work if I check a different element to determine the color status of the element of interest? 

My latest programming is:

If IssueClosed ="N"
{

     RGBColor(BasicDescription, 0,0,0,255,255,255)
}

This programming behaves the same way, that is, the screen appears to lock up, but if I activate a different tab in Sesame and then return to the tab of interest it is fine.

Any suggestions?
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Element color changes in Table View
Reply #9 - Jul 22nd, 2013 at 1:12pm
Print Post Print Post  
No. I am saying that you should only affect the element that is being drawn as part of the event. In the code I reposted, you are affecting (changing), BasicDescription and IssueClosed. I don't know which element has the On Draw event. But if you want to affect two different elements, you will need to put code in each of their On Draw events.

I am not positive that that is what is causing your "double drawing", but it is likely. When you are in an On Draw for a particular element, there is a already a context established for that element, including its "pen", "brush", and "clip region". If you then draw something else, while in that element's context, its context is forced to apply to the other element as well. Usually, not a real big deal, but the clip region may be causing some grief.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: Element color changes in Table View
Reply #10 - Jul 22nd, 2013 at 1:54pm
Print Post Print Post  
I don't know what "pen", "brush" and "clip region" are.  My latest programming tries to affect only one element, yet I still get the error effect. 

I guess I'll have to eliminate this programming and live with the color not being correct in table view.  No big deal.

  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Element color changes in Table View
Reply #11 - Jul 22nd, 2013 at 8:09pm
Print Post Print Post  
NHUser wrote on Jul 22nd, 2013 at 1:54pm:
My latest programming tries to affect only one element, yet I still get the error effect. 


Is the code in that element's On Draw event?
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: Element color changes in Table View
Reply #12 - Jul 22nd, 2013 at 8:35pm
Print Post Print Post  
My latest program is in the correct element's On Draw event.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Element color changes in Table View
Reply #13 - Jul 22nd, 2013 at 9:23pm
Print Post Print Post  
I just tried:
Code
Select All
RGBColor(city, 255, 128, 0, 0, 0, 0)
 



in the On Draw event for "City" in the "Countries.db" sample program. City is the first column in a "cities" table on the form. No ill effects. Changed color nicely.

Maybe Ray is right and something is interfering.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged