popup <widget>

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
stam
Posts: 2679
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

popup <widget>

Post by stam » Tue Dec 13, 2022 2:22 am

Hi all,

I had seen the LC video on polyGrid (shown here: https://livecode.com/polygrid-widget-in-the-spotlight/) and the last bit caught my eye : 'use polyGrid to customise popup menus'

I thought I'd use this on a project and thought the popup command could be used, but that seems not to be the case as trying it just produces a great semi-opaque rect.
According to the documentation, the syntax is:
popup widget <kind> [at <location>] [with <properties>]
As far as I can tell, this means I cannot popup an instance of a widget (in this case a polyGrid) I modified, but rather it launches a generic instance in a rect that has to be defined as a key of the properties array that needs to be passed to the command.

I mean I could use a hidden widget, show it at the clickloc and hide it again, but that seems a bit lame.
I can't get the properties of a polygrid widget as a collection (ie put the properties of widget "myPolyGrid" into tArray just returns an empty array) which means I'd have to individually add a long number of properties to the array to pass to popup, and because I modified a larger number of props that's just not practical...

Am I missing an obvious way to do this, or is showing a hidden object at the clickloc the only way to do this? I was thinking it's something I'd like to be able to access from any card - would the only way then be that this is a hidden background group that is shown at the clickLoc (which means I'd have to add to each card as well?)

Many thanks
Stam

stam
Posts: 2679
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: popup <widget>

Post by stam » Tue Dec 13, 2022 3:20 am

Further to this, I tried the following but although I can get a 'prototype' polygrid on a different page to render as a popup, it causes an error:

- I create a 'prototype' polygrid that is meant to be used as a popup and noted it's ID.

- I created a button (as a test) on a different card with the script:

Code: Select all

on mouseDown
    local tProps
    put getPGProps(283408) into tProps // the id of the prototype
    popup widget "com.livecode.widget.polygrid" with tProps
end mouseDown
where I gather the individual properties of a polygrid and return them as above with the script:

Code: Select all

function getPGProps pGPID // polygrid widget
    local tProps
    put the rect of widget id pGPID into tProps["rect"]
    put the alternateRowColors of widget id pGPID into tProps["alternateRowColors"]
    put the hGrid of widget id pGPID into tProps["hGrid"]
    put the hilitedRow of widget id pGPID into tProps["hilitedRow"]
    put the hScroll of widget id pGPID into tProps["hScroll"]
    put the lineColor of widget id pGPID into tProps["lineColor"]
    put the lineSize of widget id pGPID into tProps["lineSize"]
    put the margin of widget id pGPID into tProps["margin"]
    put the mouseHoverHilite of widget id pGPID into tProps["mouseHoverHilite"]
    put the pgAutoHilite of widget id pGPID into tProps["pgAutoHilite"]
    put the pgBackgroundColor of widget id pGPID into tProps["pgBackgroundColor"]
    put the pgBorderColor of widget id pGPID into tProps["pgBorderColor"]
    put the pgColumnNames of widget id pGPID into tProps["pgColumnNames"]
    put the pgColumnLabels of widget id pGPID into tProps["pgColumnLabels"]
    put the pgColumns of widget id pGPID into tProps["pgColumns"]
    put the pgColumnWidths of widget id pGPID into tProps["pgColumnWidths"]
    put the pgData of widget id pGPID into tProps["pgData"]
    put the pgHiliteColor of widget id pGPID into tProps["pgHiliteColor"]
    put the pgHilitedTextColor of widget id pGPID into tProps["pgHilitedTextColor"]
    put the pgTextColor of widget id pGPID into tProps["pgTextColor"]
    put the rowAlternateColor of widget id pGPID into tProps["rowAlternateColor"]
    put the rowColor of widget id pGPID into tProps["rowColor"]
    put the rowHeight of widget id pGPID into tProps["rowHeight"]
    put the scrollbarBackgroundColor of widget id pGPID into tProps["scrollbarBackgroundColor"]
    put the scrollbarBorderColor of widget id pGPID into tProps["scrollbarBorderColor"]
    put the scrollbarWidth of widget id pGPID into tProps["scrollbarWidth"]
    put the showHeader of widget id pGPID into tProps["showHeader"]
    put the vGrid of widget id pGPID into tProps["vGrid"]
    put the vScrollBar of widget id pGPID into tProps["vScrollBar"]
    
    return tProps
end getPGProps

The polygrid does actually popup and renders correctly - but I also get a non-specific IDE error that has to be closed manually so it dismisses the popped up polygrid (there is no remote debugging, I presume this is an internal LC issue):
Screenshot 2022-12-13 at 02.17.04.png

Any suggestions?
S.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3999
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: popup <widget>

Post by bn » Tue Dec 13, 2022 1:50 pm

Hi Stam,

I tried your code and had the same error message you have seen.

However when I unselected "Script Debug Mode" from the develpment menu it worked as intended without error message.

I would consider this a bug.

Kind regards
Bernd

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3999
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: popup <widget>

Post by bn » Tue Dec 13, 2022 3:05 pm

However I can't get any message back from the widget once it is in popUp mode. When clicked it closes alright but I expected e.g. a "cellClick" message.

KInd regards
Bernd

stam
Posts: 2679
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: popup <widget>

Post by stam » Tue Dec 13, 2022 3:37 pm

Thanks Bernd, I’ll test again after work…
Do you think this is a polygrid-specific bug?
I haven’t really tested this with other widgets (just with a couple of datepickers that seemed to work fine…)

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3999
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: popup <widget>

Post by bn » Tue Dec 13, 2022 4:43 pm

stam wrote:
Tue Dec 13, 2022 3:37 pm
Do you think this is a polygrid-specific bug?
I haven’t really tested this with other widgets (just with a couple of datepickers that seemed to work fine…)
I have no idea, this is unchartered territory for me.
Do you have a working example of a datePicker widget as popUp? What does it return and how do you trap it?

Kind regards
Bernd

Simon Knight
Posts: 854
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: popup <widget>

Post by Simon Knight » Tue Dec 13, 2022 5:40 pm

Which version of livecode are you using?
best wishes
Skids

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3999
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: popup <widget>

Post by bn » Tue Dec 13, 2022 6:00 pm

Hi Simon,

I am using version 9.6.9 rc2.

Kind regards
Bernd

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7229
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: popup <widget>

Post by jacque » Tue Dec 13, 2022 10:35 pm

I just tried it in LC 10.0.0dp4 and it acted as Stam described. I thought I could save a bit of scripting and pass "the properties of widget" instead of listing them all, but no properties are returned. I tried customProperties too but nothing came back there either.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

stam
Posts: 2679
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: popup <widget>

Post by stam » Wed Dec 14, 2022 1:30 am

bn wrote:
Tue Dec 13, 2022 4:43 pm
Do you have a working example of a datePicker widget as popUp? What does it return and how do you trap it?

Kind regards
Bernd
Hi Bernd, I had done this with a date picker without really looking into it in depth - having looked at it again, I get the impression that a particular 'version' of the widget pops up (presumably that has to be catered for in its creation). It returns either an empty value in the result if the user selects a date (which is then accessible in 'it') or returns 'Cancel' in 'the result' if the user dismisses the popup without clicking on a value.

I presume this is just missing functionality in the polygrid widget, meaning it probably can't be used with this command - but that's just speculation on my end.

I attach a test stack with a couple of date pickers and a polygrid. The latter indeed doesn't generate an error if dev tools are suspended, but I also can't see a way to use it :-(
I presume a widget has to be built with the popup functionality required for it to work and polygrid doesn't have it...


jacque wrote:
Tue Dec 13, 2022 10:35 pm
I just tried it in LC 10.0.0dp4 and it acted as Stam described. I thought I could save a bit of scripting and pass "the properties of widget" instead of listing them all, but no properties are returned. I tried customProperties too but nothing came back there either.
Hi Jacque, yep... hence the arduous function :-/

====
EDIT: Just FYI, the 'calendar' widget in the test stack is (or at least used to be) freely available on the LC website store. The 'date picker' widget I think was installed with the megabundle. I assume you need to have these installed for this to work...
Attachments
popup test.livecode.zip
(2.47 KiB) Downloaded 58 times

prometheus
Posts: 40
Joined: Sun Dec 13, 2015 6:05 pm

Re: popup <widget>

Post by prometheus » Wed Dec 14, 2022 3:38 am

stam wrote:
Tue Dec 13, 2022 3:20 am
Further to this, I tried the following but although I can get a 'prototype' polygrid on a different page to render as a popup, it causes an error:

- I create a 'prototype' polygrid that is meant to be used as a popup and noted it's ID.

- I created a button (as a test) on a different card with the script:

Code: Select all

on mouseDown
    local tProps
    put getPGProps(283408) into tProps // the id of the prototype
    popup widget "com.livecode.widget.polygrid" with tProps
end mouseDown
where I gather the individual properties of a polygrid and return them as above with the script:

Code: Select all

function getPGProps pGPID // polygrid widget
    local tProps
    put the rect of widget id pGPID into tProps["rect"]
    put the alternateRowColors of widget id pGPID into tProps["alternateRowColors"]
    put the hGrid of widget id pGPID into tProps["hGrid"]
    put the hilitedRow of widget id pGPID into tProps["hilitedRow"]
    put the hScroll of widget id pGPID into tProps["hScroll"]
    put the lineColor of widget id pGPID into tProps["lineColor"]
    put the lineSize of widget id pGPID into tProps["lineSize"]
    put the margin of widget id pGPID into tProps["margin"]
    put the mouseHoverHilite of widget id pGPID into tProps["mouseHoverHilite"]
    put the pgAutoHilite of widget id pGPID into tProps["pgAutoHilite"]
    put the pgBackgroundColor of widget id pGPID into tProps["pgBackgroundColor"]
    put the pgBorderColor of widget id pGPID into tProps["pgBorderColor"]
    put the pgColumnNames of widget id pGPID into tProps["pgColumnNames"]
    put the pgColumnLabels of widget id pGPID into tProps["pgColumnLabels"]
    put the pgColumns of widget id pGPID into tProps["pgColumns"]
    put the pgColumnWidths of widget id pGPID into tProps["pgColumnWidths"]
    put the pgData of widget id pGPID into tProps["pgData"]
    put the pgHiliteColor of widget id pGPID into tProps["pgHiliteColor"]
    put the pgHilitedTextColor of widget id pGPID into tProps["pgHilitedTextColor"]
    put the pgTextColor of widget id pGPID into tProps["pgTextColor"]
    put the rowAlternateColor of widget id pGPID into tProps["rowAlternateColor"]
    put the rowColor of widget id pGPID into tProps["rowColor"]
    put the rowHeight of widget id pGPID into tProps["rowHeight"]
    put the scrollbarBackgroundColor of widget id pGPID into tProps["scrollbarBackgroundColor"]
    put the scrollbarBorderColor of widget id pGPID into tProps["scrollbarBorderColor"]
    put the scrollbarWidth of widget id pGPID into tProps["scrollbarWidth"]
    put the showHeader of widget id pGPID into tProps["showHeader"]
    put the vGrid of widget id pGPID into tProps["vGrid"]
    put the vScrollBar of widget id pGPID into tProps["vScrollBar"]
    
    return tProps
end getPGProps

The polygrid does actually popup and renders correctly - but I also get a non-specific IDE error that has to be closed manually so it dismisses the popped up polygrid (there is no remote debugging, I presume this is an internal LC issue):
Screenshot 2022-12-13 at 02.17.04.png


Any suggestions?
S.


Hi Stam, this problem seems to be related to the IDE geometry library, a workaround would be to add this to the getPGProps function

Code: Select all

put  "on resizeControl;end resize control" into tProps["script"]
This way the resizecontrol won't pass to the geometry lib

prometheus
Posts: 40
Joined: Sun Dec 13, 2015 6:05 pm

Re: popup <widget>

Post by prometheus » Wed Dec 14, 2022 3:43 am

stam wrote:
Wed Dec 14, 2022 1:30 am
bn wrote:
Tue Dec 13, 2022 4:43 pm
Do you have a working example of a datePicker widget as popUp? What does it return and how do you trap it?

Kind regards
Bernd
Hi Bernd, I had done this with a date picker without really looking into it in depth - having looked at it again, I get the impression that a particular 'version' of the widget pops up (presumably that has to be catered for in its creation). It returns either an empty value in the result if the user selects a date (which is then accessible in 'it') or returns 'Cancel' in 'the result' if the user dismisses the popup without clicking on a value.

I presume this is just missing functionality in the polygrid widget, meaning it probably can't be used with this command - but that's just speculation on my end.

I attach a test stack with a couple of date pickers and a polygrid. The latter indeed doesn't generate an error if dev tools are suspended, but I also can't see a way to use it :-(
I presume a widget has to be built with the popup functionality required for it to work and polygrid doesn't have it...


jacque wrote:
Tue Dec 13, 2022 10:35 pm
I just tried it in LC 10.0.0dp4 and it acted as Stam described. I thought I could save a bit of scripting and pass "the properties of widget" instead of listing them all, but no properties are returned. I tried customProperties too but nothing came back there either.
Hi Jacque, yep... hence the arduous function :-/

====
EDIT: Just FYI, the 'calendar' widget in the test stack is (or at least used to be) freely available on the LC website store. The 'date picker' widget I think was installed with the megabundle. I assume you need to have these installed for this to work...
the returned value when the PolyGrid is used as a popup seems to be an array so doing this :

Code: Select all

on mouseUp
    local tProps
    
    put getPGProps(1004) into tProps
    popup widget "com.livecode.widget.polygrid" with tProps
    if it is not "cancel" then answer it[line 1 of the keys of it]["test"]
end mouseUp
will give you the desired result.
Also you may use it[line 1 of the keys of it] to get the full content of the clicked line, if you want to store more data in invisible columns or so
(using your stack as reference )

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3999
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: popup <widget>

Post by bn » Fri Dec 16, 2022 3:48 pm

prometheus wrote:
Wed Dec 14, 2022 3:38 am
Hi Stam, this problem seems to be related to the IDE geometry library, a workaround would be to add this to the getPGProps function

Code: Select all

put  "on resizeControl;end resize control" into tProps["script"]
This way the resizecontrol won't pass to the geometry lib
Hi Prometheus,

Thank for you input. Unfortunately your suggested workaround for the error message "remote debugger..." does not work an the error message still pops up and it only works when turning "Script Debugging" off.

From the dictionary:
The resizeControl message is only sent when the user resizes a
control by dragging its handles. It is not sent if a
handler changes the size of a control by changing its
properties (width, height, and so on).
Trapping "resizeControl" is not expected to help here.

I think that the PolyGrid is a wonderful widget and has a lot of virtues but I am afraid using it as a popUp stretches its usefulness a bit too far.
(Think setUp and decoding the return text from its array)

Kind regards
Bernd

stam
Posts: 2679
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: popup <widget>

Post by stam » Fri Dec 16, 2022 6:48 pm

bn wrote:
Fri Dec 16, 2022 3:48 pm
I think that the PolyGrid is a wonderful widget and has a lot of virtues but I am afraid using it as a popUp stretches its usefulness a bit too far.
(Think setUp and decoding the return text from its array)

Kind regards
Bernd
I came to the same conclusion so far - it can still be used as a pretend popup though (by toggling it's visibility and positioning it) and probably has something to offer for more complex setups where graphics and text should be combined... In truth, there's not many widgets that are useful as popups I suspect (then again there's not many widgets around in general! - not easy to get into as I'm discovering...)

S.

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”