com.livecode.widget.ColorPicker

Moderators: LCMark, LCfraser

pink
Posts: 224
Joined: Wed Mar 12, 2014 6:18 pm

com.livecode.widget.ColorPicker

Post by pink » Mon Aug 20, 2018 1:00 am

Is there such a widget as "com.livecode.widget.ColorPicker"?

I was trying to follow the "PopupWidget" example:

Code: Select all

private variable mColor as Color

public handler OnClick()
	variable tProperties as Array
	put the empty array into tProperties
	put mColor into tProperties["currentColor"]

	popup widget "com.livecode.widget.ColorPicker" at the mouse position with properties tProperties
	if the result is not nothing then
		put the result into mColor
		redraw all
	end if
end handler

public handler OnPaint()
	...
	set the paint of this canvas to solid paint with color mColor
	...
end handler
all I get is a faint grey rectangle
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know

pink
Posts: 224
Joined: Wed Mar 12, 2014 6:18 pm

Re: com.livecode.widget.ColorPicker

Post by pink » Tue Aug 21, 2018 2:45 pm

I still can't find any other reference to "ColorPicker"
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know

livecodeali
Livecode Staff Member
Livecode Staff Member
Posts: 168
Joined: Thu Apr 18, 2013 2:48 pm

Re: com.livecode.widget.ColorPicker

Post by livecodeali » Wed Aug 22, 2018 3:53 pm

There is no such widget - I think the docs were intended to be illustrative rather than literal there. It would be better to replace with a working example though, so it could be changed to "com.livecode.widget.iconpicker" with selectedIcon instead of currentColor.

If you are asking because you actually want a color picker, we don't have one that's pure LCB - there's "com.livecode.widget.colorswatch" but currently it's a little useless to pop up as it is coded in the IDE to 'answer color' on mouseUp, rather than directly in LCB to execute script.

livecodeali
Livecode Staff Member
Livecode Staff Member
Posts: 168
Joined: Thu Apr 18, 2013 2:48 pm

Re: com.livecode.widget.ColorPicker

Post by livecodeali » Wed Aug 22, 2018 3:59 pm

In general widgets require specific coding to handle the case when they are popped up by some other script

pink
Posts: 224
Joined: Wed Mar 12, 2014 6:18 pm

Re: com.livecode.widget.ColorPicker

Post by pink » Wed Aug 22, 2018 6:50 pm

I was mostly just trying to make the example work, though a color picker would be a great widget

so for a popup widget... do i need to program the widget separately to return the value to the parent? I'm ssuming I can't just use any widget since there needs to be some way to get a specific value...
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know

livecodeali
Livecode Staff Member
Livecode Staff Member
Posts: 168
Joined: Thu Apr 18, 2013 2:48 pm

Re: com.livecode.widget.ColorPicker

Post by livecodeali » Fri Aug 24, 2018 10:56 am

It doesn't have to be a whole new widget, but yes, within the widget you need specific logic for returning a value - see the 'currently popped up' syntax in the dictionary, or the code in the icon picker.

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1783
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: com.livecode.widget.ColorPicker

Post by [-hh] » Fri Aug 24, 2018 12:36 pm

shiftLock happens

pink
Posts: 224
Joined: Wed Mar 12, 2014 6:18 pm

Re: com.livecode.widget.ColorPicker

Post by pink » Fri Aug 24, 2018 5:21 pm

Is it working in LC9 yet?
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1783
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: com.livecode.widget.ColorPicker

Post by [-hh] » Sun Aug 26, 2018 7:03 pm

pink wrote:Is it working in LC9 yet?
I tried today. The widget works in LC 9 but it crashes LC immediately when saving.

This was my last trial with widgets and LC 9.0, sorry.
(It's so frustrating, most widgets that worked in LC 8 crash now LiveCode 9. Obviously there are several undocumented LCB changes from LC 8 to LC 9. I cannot work this way.)
shiftLock happens

bwmilby
Posts: 212
Joined: Wed Jun 07, 2017 5:37 am
Location: New Orleans, LA
Contact:

Re: com.livecode.widget.ColorPicker

Post by bwmilby » Mon Aug 27, 2018 12:24 am

I’m sure there are a few that would look at the code to help track down where the issues are.
Brian Milby

Script Tracker https://github.com/bwmilby/lc-misc/tree/master/ScriptTracker

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1783
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: com.livecode.widget.ColorPicker

Post by [-hh] » Mon Aug 27, 2018 1:50 am

Here is the source code.
The attached demo stack works perfectly in LC 8 but crashes LC 9 when saving.
Looking into the lcb file may hopefully help 'pink' for his own picker.
Attachments
hhcolorpicker.lcb.zip
(6.15 KiB) Downloaded 46 times
hhColorPicker_Demo.livecode.zip
(1.83 KiB) Downloaded 44 times
shiftLock happens

bwmilby
Posts: 212
Joined: Wed Jun 07, 2017 5:37 am
Location: New Orleans, LA
Contact:

Re: com.livecode.widget.ColorPicker

Post by bwmilby » Mon Aug 27, 2018 6:11 am

I think it just needs one or both of these handlers (probably just the first one):

Code: Select all

public handler OnSave(out rProperties as Array)
	put the empty array into rProperties
	return rProperties
end handler

public handler OnLoad(in pProperties as Array)
end handler
When I added them, I was able to save the demo stack to another location and it retained the changed colors. Before I made the change, a corrupted version of the stack was left (with the ~ version also remaining).

I'm not sure if this is a bug or an intended change. I wouldn't think LC should crash if the OnSave handler is missing (since in this case it was omitted on purpose). I did look at the docs, and it just says that the core handlers should be included.
Brian Milby

Script Tracker https://github.com/bwmilby/lc-misc/tree/master/ScriptTracker

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1783
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: com.livecode.widget.ColorPicker

Post by [-hh] » Mon Aug 27, 2018 11:11 am

Many thanks for solving this.
bwmilby wrote:I'm not sure if this is a bug or an intended change. I wouldn't think LC should crash if the OnSave handler is missing (since in this case it was omitted on purpose). I did look at the docs, and it just says that the core handlers should be included.
I think none of the widgets on github (livecode/extensions/widgets/) has all core handlers included. For example colorswatch.lcb contains not OnSave() nor OnLoad().
bwmilby wrote:Before I made the change, a corrupted version of the stack was left (with the ~ version also remaining).
The stack bears possibly another problem because it contains the LC 8 widget. But without the OnSave() the widget crashed LC 9 also with a new stack.

Anyway: As soon as the widget is installed in LC 9 it is removed for LC 8. So it is impossible to develop for LC 9 and LC 8 at the same time.

LC 8 is much more stable than the regularly crashing LC 9. I had no crash with final widgets until now with LC 8.
Of course, one could do an automatic recompiling/reinstalling when switching LC8/LC9 as LC does. But by that one cannot use one of the (recently very rare) new LCB-features ...

So currently it is, sadly, better to stay with LC 8.
shiftLock happens

bwmilby
Posts: 212
Joined: Wed Jun 07, 2017 5:37 am
Location: New Orleans, LA
Contact:

Re: com.livecode.widget.ColorPicker

Post by bwmilby » Mon Aug 27, 2018 11:36 pm

The release of LC 9 fixed the recompile issue. What you need to do is update the source code and install in LC 8. When you launch LC 9 it will recompile the widget for LC 9 but leave the working code for LC 8 as long as the lcb file is present. The files are "module.lcm" and "module.2.lcm"
Brian Milby

Script Tracker https://github.com/bwmilby/lc-misc/tree/master/ScriptTracker

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1783
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: com.livecode.widget.ColorPicker

Post by [-hh] » Tue Aug 28, 2018 11:04 am

Brian wrote:The release of LC 9 fixed the recompile issue. What you need to do is update the source code and install in LC 8. When you launch LC 9 it will recompile the widget for LC 9 but leave the working code for LC 8 as long as the lcb file is present. The files are "module.lcm" and "module.2.lcm"
1.
This is no good solution because it should only check whether there is already a .lcm or .2.lcm file respectively. The installed widget needs only lcm, not lcb. But excluding the lcb file from the package is currently the only way to 'protect' the widget.

2.
This makes only sense for code that runs both in LC 8 and LC 9. This is sadly a strong LCB subset of *both* LC 8 and LC 9:
There is LCB 8 code that doesnt't compile with LCB 9 and there is LCB 9 code (not only new features) that doesn't compile with LCB 8.

Until this isn't solved I see no way to write a more than simple widget for both LCB 8 and (the still 'unfinished') LCB 9.
shiftLock happens

Post Reply

Return to “LiveCode Builder”