Announcement

Collapse
No announcement yet.

Magic Event called by multiple buttons

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Magic Event called by multiple buttons

    Hello,

    I'm trying to consolidate some code and I'd like to use the same MagicEvent to address several different buttons. How can I distinguish which button has been pushed in the event code?

    Right now, I have multiple events doing very simple things for each button and would like to remedy that.

    Best regards,

    Christian

  • #2
    Hi Christian,


    Welcome to the forum!


    If this is the case, other way is, you could use MagicTouch to distinguish which button has been pushed.


    Below is the working code example:


    MagicCode0.inc (set InsertPoint ---> Constant/Global/Data)
    Code:
    var count;

    MagicTouch.inc
    Code:
    txt_MoveCursor(1,0);
    
    if (ImageTouched == iWinbutton0)
        print("Winbutton0");
    endif
    if (ImageTouched == iWinbutton1)
        print("Winbutton1");
    endif
    
    ImageTouched := -1;        // used to stop Genie processing the object ‘later on’ - refer to manual


    Also, I have attached the ViSi-Genie demo project of this.


    Hopefully, this will help you.


    Best regards,
    Kayven
    Attached Files

    Comment


    • #3

      A simple method can achieve this, within the MagicEvent. You can use the global variable ImageTouched.


      As shown below:


      MagicEvent
      Code:
      txt_MoveCursor (2,0);
      print (ImageTouched);
      Best Regards.
      Kayven


      Last edited by [email protected]; 15th February 2019, 11:06 AM.

      Comment

      Working...
      X