untill it someone has a better solution would this help?
B4X:
sub appstart
addevent("button1",Click,"ev1")
addevent("form1",MouseUp,"ev2")
addevent("timer1",Tick ,"ev3")
end sub
sub ev1
ev("Button")
end sub
sub ev2
ev("MouseUp")
end sub
sub ev3
ev("Tick")
end sub
sub ev(showtype)
MsgBox("Type " & showtype)
end sub
no,you dont understand me=)
for example i have 100 controls...and i must add 100 subs?
but this problem i have?when i create plugins for my program with Scripting dll
plugins can arr objects to program but now i want add events for this objects,and code of this events in plugin.
No. Just have one event Sub for each type of event then you know the Event type and can use Sender for the source of the event.
B4X:
sub appstart
addevent("button1","Click","clickev")
addevent("form1","MouseUp","mupev")
addevent("timer1","Tick","tickev")
end sub
sub clickev
...
end sub
sub mupev
...
end sub
sub tickev
...
end sub
i think about it,but in program used all(maybe not all but many) controls and objects from any dlls and i must create very many subs includes all events...
it is not good too...
and most importantly it is unnecessary, it may be sufficient to know what event
No, it is not possible. It would need a modification to Basic4ppc to save the event name as well as the sender name. Presently the event name is lost once the event sub has been identified by the Basic4ppc event code.
Surely there are not that many events you need, and surely it is better to have small individual event Subs handling each type of event rather than one huge Sub with lots of conditional tests inside it trying to handle all the possible event types!
EDIT:- Remember that you don't need a different event sub for each control or object, only different ones for each individual event name. You can hide them in a module!
Also notice that the event sub must match the number of arguments. So the event sub of a MouseUp event should have two parameters (and you can't use the same sub for the Click event).
thanks erel, but it was example and in my app some events not been used(mouseup,mousedown,mousemove,keypress).
but what you say about add new keyword in basic in latest version? =)