Editing datagrid triggers openStack

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
ronn
Posts: 26
Joined: Sun Apr 09, 2006 6:14 pm

Editing datagrid triggers openStack

Post by ronn » Sun May 17, 2009 12:56 am

Hi RevFolks.

One of the problems I'm having with datagrids is that whenever I click the Row Template button or click the plus sign to add a Column Behavior, the openStack handler of my main stack is triggered. Is this just happening to me?

You can duplicate the problem (well, I can duplicate the problem) just by starting a new main stack, adding a dummy openStack handler to display a msg, drag in a datagrid and from its Properties dialog click the RowTemplate button. Doesn't that display the message from your openStack handler?

In my case, my datagrid is on a substack but it still triggers the main stack's handler. Which, again in my case, gives me an error since something my openStack is looking for on the main stack doesn't exist on the substack. And the error often prevents me from getting any further with the Row Template. The beginning of an endless circle.

Is this happening to anyone else. Any way to stop it? As far as I know I'm using the latest Rev 3.5 (Vista 64-bit).

Thanks for any info.

Ron

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Sun May 17, 2009 7:26 am

It's the nature of the message path: when an openStack message is sent to a substack, and that substack doesn't handle it, then the message will pass along to the mainstack, etc. See Richard Gaskin's excellent article explaining the Revolution message path.

The easiest solution is to check the target in your openStack handler.

Code: Select all

on openStack
  if the target is not me then pass openStack
  -- now do your normal stuff
  ...
  -- finally let other layers handle the message
  pass openStack
end openStack
The message path (a variant on the command chain design pattern often applied in object-oriented programming) is a very powerful aspect of Revolutiion development, so it's best to learn its peculiarities and exploit its flexibility.

HTH,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

ronn
Posts: 26
Joined: Sun Apr 09, 2006 6:14 pm

Post by ronn » Sun May 17, 2009 3:52 pm

Thanks Jan.

Now it's so obvious! :oops: What didn't dawn on me was that clicking RowTemplate was actually opening a new stack which would set off the msg path. And that template stack is a substack of the main stack rather than a substack of the substack on which the datagrid existed. Which explains why the openStack of my substack didn't trigger. I guess.

Thanks for the explanation and the "check the target" idea which will be implemented. Now all I need to figure out is where to put code to write any changes to the datagrid data back to the source database. And how difficult could that possibly be?! Thanks again.

... Ron

Post Reply