color selection

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

color selection

Post by keram » Wed May 07, 2014 6:17 am

Hi,

I found this lesson about a color picker swatch http://lessons.runrev.com/m/4071/l/7522 ... ker-swatch
and followed the steps in it.

The code in an opaque graphic on a card is:

Code: Select all

global gTheChosenColor
on mouseUp pBtnNum
    if pBtnNum is 1 then
        answer color with the effective backgroundcolor of me
        if the result is not "cancel" then
            put it into gTheChosenColor
            set the backgroundcolor of me to gTheChosenColor
        end if
     end if
     set the textColor of fld "fSample" to gTheChosenColor
end mouseUp
and after compiling the standalone no standard color-selection dialog box shows up.
It works OK in Windows but not in Android.

Any ideas why?

keram
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: color selection

Post by Simon » Wed May 07, 2014 6:52 am

Hi keram,
"answer color" is not for mobile.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: color selection

Post by keram » Wed May 07, 2014 9:37 am

Thanks Simon,

Yeah, I overlooked it in the dictionary...
So what are the alternatives?
Three sliders adjusting the RGB values? That's little awkward...

I've seen in one app this nice colour picker:
colorpicker2.png
colorpicker2.png (14.35 KiB) Viewed 6492 times
but I don't know if it's possible to incorporate it into LC stack and how...

keram
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: color selection

Post by Simon » Wed May 07, 2014 9:46 am

Hi keram,
I think you would use the "mousecolor", you have to make your own color pallet.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: color selection

Post by keram » Thu May 08, 2014 5:53 pm

Thanks Simon,

I was not aware of the mouseColor function.

I created now my own color picker with a palette (an image consisting of squares of different colors) and 2 radio buttons, one for changing the text color and the other for changing background color. I want to do it on certain selected cards only and just in some fields on these cards (cards are marked and the names of these fields start with letter f).

I'm using this code:

Code: Select all

global gTextColor, gBackColor
on mouseUp
   put the effective rect of img  "palette" of me into tPalette
   if the mouseH > item 1 of tPalette and the mouseH < item 3 of tPalette \ 
         and the mouseV > item 2 of tPalette and the mouseV < item 4 of tPalette then
      if the hilite of btn "font" of me then
         put the mouseColor into gTextColor
         set the textColor of fld "fSample" to gTextColor
      else if the hilite of btn "bckgr" of me then
         put the mouseColor into gBackColor
         set the backColor of fld "fSample" to gBackColor
      end if
   end if
   changeColor
end mouseUp

on changeColor
   set the itemDel to comma
   repeat with i = 1 to the number of cards of this stack
      if the mark of card i is true then
         put the name of cd i & comma after tMarkedCards
         if the hilite of btn "bckgr" of me then set the backColor of cd i to gBackColor
      end if
   end repeat
   
   repeat for each item tCard in tMarkedCards
      repeat with j = 1 to the number of flds of tCard
         if the hilite of btn "font" of me then
            if the short name of fld j of tCard contains "f" then set the textColor of fld j of tCard to gTextColor
         end if
      end repeat
   end repeat
end changeColor
It works perfectly in IDE and in Windows standalone but not at all in Android app.

What's wrong here?

keram
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: color selection

Post by Klaus » Thu May 08, 2014 6:54 pm

And again a look into the dictionary brings full enlightment! 8)

Since there is no "mouse" on mobile, "the mousecolor" is only supported on desktop Mac, Win , Linux!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: color selection

Post by jacque » Thu May 08, 2014 7:47 pm

There may be an error in the dictionary, it says mousecolor works on mobile. Or else there's a bug in the engine. One of them is wrong.

Edit: I'm looking at the 6.6.1 dictionary. Maybe it's been changed in later versions?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: color selection

Post by Klaus » Thu May 08, 2014 10:59 pm

Oops, yes, sure, sorry for that, no idea where I had been looking? :oops:

But maybe you should try to use "mousedown" or "touchstart" instead of "mouseup"! 8)

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: color selection

Post by Dixie » Thu May 08, 2014 11:11 pm

Klaus ...

The 'mouseColor' is supported on mobile... just ran in 6.6.2(rc3)
OOPS: apologies... I failed to notice that this was concerning Android :oops:
Attachments
mousecolor.zip
(1.53 KiB) Downloaded 216 times
Last edited by Dixie on Fri May 09, 2014 8:04 am, edited 1 time in total.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: color selection

Post by Simon » Fri May 09, 2014 12:22 am

Seems the "mouseColor" is broken on Android.
Returns 0,0,0 for all colors tested.

keram, will you bug report it?
Dixie's stack shows it.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: color selection

Post by keram » Fri May 09, 2014 1:29 am

Hello Friends,

Thanks for your valuable responses.
Dixie wrote:The 'mouseColor' is supported on mobile... just ran in 6.6.2(rc3)

Currently I'm using v. 6.5.2. I switched from v. 6.6.1 to this earlier version because I got "scared" by this posting:
http://ftp.runrev.com/forums/viewtopic. ... f3ca20002d
I simply don't want to create any sluggish apps... and my app will have few images in it, not moving but still...
Simon wrote:keram, will you bug report it?
Yes, I'll do it.

keram
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Post Reply