[Gambas-user] Which button was clicked?

GuruLounge - MailLists maillists at ...1367...
Mon Mar 20 18:26:37 CET 2006


I'm trying to create a form that generates buttons dynamically
depending on items in a list.  I've been doing some testing before I try
to implement this but I'm not having any luck determining which button
has raised the event.  Here's some sample code:


---------------------------
<<MAIN module>>

PUBLIC SUB test()
DIM btnNew AS toolbutton

myForm.Load
myForm.Show

btnNew = NEW ToolButton(myForm)
btnNew.Top = 0
btnNew.Left = 0
btnNew.Caption = "test01"
btnNew.Tag = "test01"

Object.Attach(btnNew, myForm, "btn")

btnNew = NEW ToolButton(myForm)
btnNew.Top = 22
btnNew.Left = 0
btnNew.Caption = "test02"
btnNew.Tag = "test02"

Object.Attach(btnNew, myForm, "btn")

END

<<myForm module>>

PUBLIC SUB btn_Click()

PRINT ME.tag & " clicked!"

END

---------------------------

The click event is raised regardless of the button I click.  This is
good.  But I'm having trouble finding documentation on how to determine
which button was clicked.  "ME" obviously refers to the form.  Which
object refers to the current button?

TIA,

Jeff

-- 

     .^.
     /V\
    /( )\
    ^^-^^
Linux Advocate





More information about the User mailing list