A shortcut for forcing a redraw when setting a property

Moderators: LCMark, LCfraser

Post Reply
trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 882
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

A shortcut for forcing a redraw when setting a property

Post by trevordevore » Thu Mar 05, 2015 3:19 pm

I'm finding that I'm having to write lots of setProps that just assign the value passed in to a property and then force a redraw. This gets a little redundant. It would be nice if we could somehow specify that the control should be redrawn whenever a property is set. Maybe something like this:

Code: Select all

property chevronYOffset       get mChevYOffset    set mChevYOffset with redraw
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

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

Re: A shortcut for forcing a redraw when setting a property

Post by LCMark » Sat Mar 07, 2015 1:40 pm

@trevordevore: This is a really good idea :)

Indeed, I think there's a generalization here - the idea of a 'trigger':

Code: Select all

property myProperty get mMyProperty set mMyProperty trigger RedrawMe
Here 'RedrawMe' would be a handler something like:

Code: Select all

handler RedrawMe
  redraw all
end handler
A further extension could be to allow any statement which takes no inputs as part of the trigger clause:

Code: Select all

property myProperty get mMyProperty set mMyProperty trigger redraw all
All that being said, 'redraw' is perhaps something which should be a flag on the property itself - can you think of any other common triggers which might see use?

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 882
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: A shortcut for forcing a redraw when setting a property

Post by trevordevore » Mon Mar 09, 2015 2:08 pm

I like the idea of a trigger. I haven't come across any other common triggers just yet. Depending on the final implementation of the sizing conversion we are having you may want to trigger a resize when setting a property.
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

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

Re: A shortcut for forcing a redraw when setting a property

Post by LCMark » Thu Mar 12, 2015 3:45 pm

@trevordevore: I've filed http://quality.runrev.com/show_bug.cgi?id=14901 to do with property triggers.

Post Reply

Return to “LiveCode Builder”