Register to post in forums, or Log in to your existing account
 

This forum is locked: you cannot post, reply to, or edit topics.  This topic is locked: you cannot edit posts or make replies.     Home » Forums » General zApp Discussion
Castaway
GURU


Joined: 10 Oct 2000
Posts: 793
Location: Swindon, England

PostPosted: Wed Aug 17, 2005 9:56 am   

Action/Script parameters? Current Object?
 
Heyho again, more delvings..

I'm trying to create a grid of buttons which all call the same action (but have different captions). The action is generic, except it needs to know which button it was called from.. Is there a way to either 1) pass parameters to actions/scripts, or 2) find out what the current object is? (i.e. in what objects context the action was called).

Both would be useful..

Lady C.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Aug 17, 2005 4:30 pm   
 
There isn't any way to pass parameters to actions. And you have uncovered a nice little bug here.

The zAction.OnExecute event is supposed to set the zEvent.Sender to the control that generated the event. Instead of setting this to the button control that is called the action, it is getting set to the action itself, which isn't correct.

So, the way it is *supposed* to work is that you'd use an action like this:
Code:
<ACTION Name='MyAction'>
  msgbox zEvent.Sender.Caption
</ACTION>

to display the caption of the button calling the action. But this doesn't work since Sender isn't set properly.

I'll add this to the bug list for the next version. I'll give some thought to how to implement action parameters, but that might be hard since a single action can be called from different controls (like a menu item and a toolbar button calling the same action). Also, if you are going to pass arguments to the action, then you might as well just override your own button script to call a subroutine or function with arguments instead.
Reply with quote
Castaway
GURU


Joined: 10 Oct 2000
Posts: 793
Location: Swindon, England

PostPosted: Sat Aug 20, 2005 7:46 am   
 
Aha.. nice bug. I can see a $MainObj->zEvent->Sender, but when I print its Caption or Name, I get a different seemingly random number each time.. Odd.

And while we're at it, there doesn't seem to be a description of the zEvent object anywhere, I was expecting to find it in "Non-Visual Objects" ..

Why don't I indeed, call the sub with arguments.. Because I tried it, and it didnt work.. And now I've just noticed I did something really stupid, and it was all my fault. So, yes.. umm, you can ignore that request if you like ;)

Lady C.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Sat Aug 20, 2005 5:34 pm   
 
zEvent is documented over in the Core Concepts area in the Event Handling topic.

Edited: Hmm, well it seems that the Event Handling topic doesn't really talk about the zEvent object. Wierd...I could have sworn it was documented somewhere.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Thu Sep 29, 2005 9:07 pm   
 
I've got this fixed in the next zApp v2.33. The zEvent.Sender for ACTION components will be set to the control that originated the action, rather than the action itself. So, for example, when an Action is assigned to a button, the zEvent.Sender property within the action script will refer to the button.
Reply with quote
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.     Home » Forums » General zApp Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
© 2009 Zugg Software. Hosted on Wolfpaw.net