Page 1 of 2

widgets & lcVCS

Posted: Sun Apr 05, 2015 2:24 am
by monte
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

Re: widgets & lcVCS

Posted: Thu Apr 09, 2015 9:42 am
by livecodeali
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

Re: widgets & lcVCS

Posted: Fri Apr 10, 2015 12:52 am
by monte
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.

Re: widgets & lcVCS

Posted: Mon Apr 13, 2015 1:45 pm
by LCMark
@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).

Re: widgets & lcVCS

Posted: Wed Apr 15, 2015 1:31 am
by monte
That would be very helpful. So we would be able to make some call that triggered OnSave and get the array returned???

Re: widgets & lcVCS

Posted: Wed Apr 15, 2015 11:33 am
by LCMark
@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.

Re: widgets & lcVCS

Posted: Tue Jun 02, 2015 5:02 am
by monte
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?

Re: widgets & lcVCS

Posted: Tue Jun 02, 2015 4:18 pm
by LCMark
@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.

Re: widgets & lcVCS

Posted: Tue Jun 02, 2015 4:25 pm
by LCMark
@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.

Re: widgets & lcVCS

Posted: Tue Jun 02, 2015 4:35 pm
by LCMark
@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.

Re: widgets & lcVCS

Posted: Tue Jun 02, 2015 5:47 pm
by LCMark

Re: widgets & lcVCS

Posted: Wed Jun 03, 2015 8:16 am
by monte
Thanks @LCMark I will have a play with what you've done and hopefully I can get LC 8 support in lcVCS happening.

Re: widgets & lcVCS

Posted: Wed Sep 09, 2015 10:53 am
by LCMark
The PRs I made to allow @monte to get lcVCS working with widgets has been merged for 8DP5.

Re: widgets & lcVCS

Posted: Wed Sep 09, 2015 11:02 am
by monte
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

Re: widgets & lcVCS

Posted: Wed Sep 09, 2015 11:18 am
by LCMark
@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).