#548 A way to forward event to another component w/o programming

3.0.0 RC
closed
nobody
General (239)
9
2007-08-19
2007-08-17
Tom M. Yeh
No

Without zscript, it is tedious to register event listener for each menuitem and buttons in a window.

For example,
<window id="w" use="MyWindow">
<button id="b" label="OK" onClick="w.onOK()"/>

requires zscript to run w.onOK, which degrades the performance.

On the other hand, we can register
class MyWindow {
void onCreate() {
getFellow("b").addEventListener(...

but it is tedious.

///Solution///
It will be better if we can

<window id="w" use="MyWindow">
<button label="onOK" event="w.onOK"/>

Then, in MyWindow,
class MyWindow {
public void onOK() {
}
...

No zscript, no addEventListener

Tom

Discussion

  • Dennis Chen

    Dennis Chen - 2007-08-17

    Logged In: YES
    user_id=386673
    Originator: NO

    I think we need to specify the type of Event, such as:
    <button label="onOK" event="onClick:w.doOK,onX:w.doY"/>
    no script, parser register listener when parsing.

    And some times I want get more information from event.
    public void doOK(Event event) {
    ..
    }

    Or, nothing in argument is Ok. too.
    public void doY() {
    ..
    }

    /Dennis

     
  • Henri Chen

    Henri Chen - 2007-08-17

    Logged In: YES
    user_id=89247
    Originator: NO

    It a way to chain event from this component's onX event to another component's onY event. So it might be look like this:

    <button label="onOK" event="onClick:w.onOK,onX:z.onY"/> rather than doOK and doY.

    It reads "button's onClick event will trigger component w's onOK event while onX event will trigger component z's onY event."

    To be more general, maybe in this form:

    <button label="onOK" event="onX1:w1.onY1,w2.onY2,...; onX2:w3.onY3, w4.onY4,..."/>

    So you can chain event to trigger multiple events.

    The issue here is how you pass the data in event? In onClick and onOK example, no data, no problem. If there is data, then ...?

     
  • Tom M. Yeh

    Tom M. Yeh - 2007-08-19
    • milestone: --> 3.0.0 RC
    • status: open --> closed
     
  • Tom M. Yeh

    Tom M. Yeh - 2007-08-19

    Logged In: YES
    user_id=91099
    Originator: YES

    Ready since 8/19
    ---
    Example,

    <button label="OK" forward="onOK"/>

    It forwards the onOK event to the space owner of the button.

     
  • Henri Chen

    Henri Chen - 2007-08-19

    Logged In: YES
    user_id=89247
    Originator: NO

    I don't follow this example. There is no onOK event in button then how do it forward that to the space owner?

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks