BackColor problem

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Maxiogee
Posts: 38
Joined: Thu May 05, 2011 5:45 pm

BackColor problem

Post by Maxiogee » Wed Aug 13, 2014 3:55 pm

In the script of a scrolling field with several lines of text I wrote…

Code: Select all

On mouseUp
   if the controlKey is up then
      put last word of (the value of the clickline) into numba
      go to card numba of stack "AllSingles"
   else
      put word 2 of the clickline into Lin
      if the backcolor of me = 255,255,255 then
         set the backcolor of line Lin of me to 255,0,150
      else
         set the backcolor of me to 255,255,255
      end if
   end if
end mouseUp
… expecting that the line would switch, with repeated clicking, between being highlighted and not being highlighted.

However, this is not what happens.
The line highlights, but a subsequent click does not unhighlight it.

When I query the field, through the message box …
> put the backcolor of line 2 of field "Last Highest"
it returns the word 'mixed'

In fact, with the line highlighted from above, when I ask the message box
put the backcolor of field "LastHighest"
it returns 255,255,255.

I cannot seem to script the field to accept the 'mixed' status as a case for reverting to a white background.

Any suggestions, please?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: BackColor problem

Post by dunbarx » Wed Aug 13, 2014 5:23 pm

Hi.

Do you have the "listBehavior" of your field set to "true"? This may interfere with the manual color changing you are trying to work. Set it to "false" (make sure that lockText is "true") and see if that helps.

Craig

sritcp
Posts: 431
Joined: Tue Jun 05, 2012 5:38 pm

Re: BackColor problem

Post by sritcp » Wed Aug 13, 2014 6:26 pm

Hi Maxiogee:

1. The existing backColor of lines in a field is empty; it is inherited from the backColor of the field unless you set it specifically.
So, if you change replace 255,255,255 with empty in your code, it should work.
The following code works:

Code: Select all

on mouseUp
   local tLine
   put word 2 of the clickLine into tLine
   if the backColor of line tLine of me is empty then
      set the backColor of line tLine of me to "yellow"
   else
      set the backColor of the clickLine to empty
   end if
end mouseUp
2. Note that mouseDown/mouseUp messages are only sent when you control-click within an unlocked field (i.e., not with simple clicks).
I am assuming that your field is locked.

Regards,
Sri.

Maxiogee
Posts: 38
Joined: Thu May 05, 2011 5:45 pm

Re: BackColor problem

Post by Maxiogee » Thu Aug 14, 2014 11:12 am

dunbarx wrote:Hi.

Do you have the "listBehavior" of your field set to "true"? This may interfere with the manual color changing you are trying to work. Set it to "false" (make sure that lockText is "true") and see if that helps.

Craig
The "listBehavior" is false
The field is not locked.

sritcp wrote: The following code works:

Code: Select all

on mouseUp
   local tLine
   put word 2 of the clickLine into tLine
   if the backColor of line tLine of me is empty then
      set the backColor of line tLine of me to "yellow"
   else
      set the backColor of the clickLine to empty
   end if
end mouseUp
Indeed it does. Many thanks.
sritcp wrote: 2. Note that mouseDown/mouseUp messages are only sent when you control-click within an unlocked field (i.e., not with simple clicks).
The field is not locked.

Thank you both.

Post Reply