widgets & lcVCS

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, LCMark

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

widgets & lcVCS

Post by monte » Sun Apr 05, 2015 2:24 am

Hi

I wasn't going to update lcVCS to support widgets because the text export was also due in 8 but @trevordevore has just told me that's now off the cards.

At the moment there's no support for the properties property so if that's going to happen soon I might wait otherwise I would need to do something like:

Code: Select all

repeat for each line theProperty in the keys of revIDEExtensionProperties(the kind of <widget reference>)
I don't really like depending on undocumented IDE functions though particularly at this early stage of development. I'd also need to use revIDEExtensions("widget", "installed") to determine if a widget in the exported stack were available in the import. Is there any chance these features might be moved to the engine:
- the extensions & the properties?

Cheers

Monte
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

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

Re: widgets & lcVCS

Post by livecodeali » Thu Apr 09, 2015 9:42 am

Hi Monte,

For the latter you can use the 'loadedExtensions' function. I don't think getting the properties will be moved to the engine though. When you get and set properties of a widget, the engine attempts to find the property handler, and if it isn't there it is treated as a custom property. So there isn't really any way to list the properties for a given module in memory.

Ali

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: widgets & lcVCS

Post by monte » Fri Apr 10, 2015 12:52 am

Thanks @livecodeali from my perspective it probably would have been good for some of the widget metadata (maybe just the property names) to be accessible to the engine for functions like the properties property to be able to work with widgets. Folks have also asked for things like the propertyNames of <objectRef> and this would have helped implement that too.
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1206
Joined: Thu Apr 11, 2013 11:27 am

Re: widgets & lcVCS

Post by LCMark » Mon Apr 13, 2015 1:45 pm

@monte: Just as with the current engine controls, the relationship between an object's script-visible properties and its internal state is not necessarily a simple one-to-one mapping. The thing that is needed for export/import of a widget is access to the state array which is generated by the OnSave handler in the widget's implementation - we'll be adding access to this from script via a suitable command shortly (and also, hopefully, extending the same ability to the existing object types; thus avoiding the head-aches and various processing required by using the 'properties' property).

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: widgets & lcVCS

Post by monte » Wed Apr 15, 2015 1:31 am

That would be very helpful. So we would be able to make some call that triggered OnSave and get the array returned???
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1206
Joined: Thu Apr 11, 2013 11:27 am

Re: widgets & lcVCS

Post by LCMark » Wed Apr 15, 2015 11:33 am

@monte: Yes - I'm intending to add some syntax which allows you to import/export an object as an array. The array will represent the objects internal state in the most appropriate way; so in the case of widgets it will be the array returned from OnSave.

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: widgets & lcVCS

Post by monte » Tue Jun 02, 2015 5:02 am

I've spent some time with this today. I can't really see any reason why widgets couldn't have a properties property by combining exported_definitions with the default set of properties. It might not be a perfect representation of the object like the OnSave method you mentioned but it would at least support the existing LC feature reasonably well. That being said one thing I will need is to know what properties are text and can safely be utf8 encoded etc. With the properties property I'd only know that for name and toolTip. Would OnSave give me better insight there? Has that been implemented yet?
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1206
Joined: Thu Apr 11, 2013 11:27 am

Re: widgets & lcVCS

Post by LCMark » Tue Jun 02, 2015 4:18 pm

@monte: The problem with that approach is that 'the properties' of widgets does not represent the state you actually need to save (this is also true of the legacy controls - but the explicit modifications to the 'properties' means that it works for that fixed set of controls).

I've implemented an initial version of object export / import:

https://github.com/runrev/livecode/pull/2345.

As it stands this is restricted to widgets and then *only* the widgets internal state. It will need a bit more work to generalize to include the non-overridable properties inherited from MCControl, and also to extend to other objects.

In regards to detecting the type of values then I wonder if we need the following operators:
  • x is strictly a boolean
  • x is strictly an integer
  • x is strictly a real
  • x is strictly an array
  • x is strictly a string
  • x is strictly a binary string
This would check the value in x for its explicit type without attempting conversion.

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1206
Joined: Thu Apr 11, 2013 11:27 am

Re: widgets & lcVCS

Post by LCMark » Tue Jun 02, 2015 4:25 pm

@monte: Alternative suggestion (since x is strictly an integer != not (x is not strictly an integer) linguistically speaking)...

x is currently a[n] integer
etc.

This reflects the fact variables can be of various different types but still be valid in other type contexts - however, variables always have an explicit 'current' type.

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1206
Joined: Thu Apr 11, 2013 11:27 am

Re: widgets & lcVCS

Post by LCMark » Tue Jun 02, 2015 4:35 pm

@monte: And another suggestion...

x is really an integer
etc.

In any case regardless of the exact token, it is a relatively easy thing to implement.

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1206
Joined: Thu Apr 11, 2013 11:27 am

Re: widgets & lcVCS

Post by LCMark » Tue Jun 02, 2015 5:47 pm


monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: widgets & lcVCS

Post by monte » Wed Jun 03, 2015 8:16 am

Thanks @LCMark I will have a play with what you've done and hopefully I can get LC 8 support in lcVCS happening.
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1206
Joined: Thu Apr 11, 2013 11:27 am

Re: widgets & lcVCS

Post by LCMark » Wed Sep 09, 2015 10:53 am

The PRs I made to allow @monte to get lcVCS working with widgets has been merged for 8DP5.

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: widgets & lcVCS

Post by monte » Wed Sep 09, 2015 11:02 am

Yay, the next question I was going to have was how to detect what types things are to work out what to utf8Encode and what not to but it turns out is really is what I need. Do you know though that the is really syntax examples all skip the 'really' part?

Code: Select all

"Hello World!" is a string -- evaluates to true
1 + 200 is an integer -- evaluates to true
(100 is 100) is a boolean -- evaluates to true
the compress of "Hello World!" is a binary string -- evaluates to true
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1206
Joined: Thu Apr 11, 2013 11:27 am

Re: widgets & lcVCS

Post by LCMark » Wed Sep 09, 2015 11:18 am

@monte: Don't is an integer and is a boolean already exist? They do implicit type conversion... If you use 'is really an integer' it will only be true if the LHS is a MCNumberRef valueref which is marked as an integer (i.e. "100" is an integer -- true; "100" is really an integer -- false).

Locked

Return to “Engine Contributors”