[Gambas-user] Which button was clicked?

ron ronstk at ...239...
Mon Mar 20 18:40:50 CET 2006


On Monday 20 March 2006 18:26, GuruLounge - MailLists wrote:
> <<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)

When I'm right here you set the _same_ btnNew with a new instance

> 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
> 

DIM btnNew AS object[]

PUBLIC SUB test()


DIM btncnt as integer
btncnt=0
btnNew[btncnt] =new toolbutton(parent) ' AS "MyDynamicButton"
INC btncnt
...
btnNew[btncnt] =new toolbutton(parent) ' AS "MyDynamicButton"
INC btncnt
...
end sub

public sub MyDynamicButton_Click()
  print Last.Tag 'not Me.Tag !
end sub

May be this gives a idea and help, untested!

Ron




More information about the User mailing list