[Gambas-user] Grouped control's events are overshadowed by the Group events

T Lee Davidson t.lee.davidson at gmail.com
Tue Sep 26 21:04:37 CEST 2023


On 9/26/23 14:44, Benoît Minisini wrote:
> Le 26/09/2023 à 20:41, T Lee Davidson a écrit :
>> On 9/26/23 14:31, Benoît Minisini wrote:
>>> Le 26/09/2023 à 20:23, T Lee Davidson a écrit :
>>>> In a project I have some ValueBoxes that I have grouped so that I can perform the same action on any one of them for the 
>>>> same event. But, I want only one of them to do something different for a different event.
>>>>
>>>> However, the individual control's event handlers are not triggered when an event handler for the group exists.
>>>>
>>>> Is this by design, or a bug?
>>>>
>>>> Small demo project attached.
>>>>
>>>
>>> This is by design. There is no "individual" or "group" event handlers. Each object has its own event handlers, all using the 
>>> same prefix. It's just that two different objects can use the same prefix (I named these prefix "event names", not a 
>>> beautiful choice).
>>
>> I'm not sure I quite understand what you mean by the "prefix". What I think you mean is that if objects are grouped, then they 
>> would all use the same prefix in the event handler name.
>>
>> But, regardless if I am understanding that correctly, if the behavior is by design, then I would need to create an event 
>> handler for the group and test Last.Name to determine whether or not to take action.
>>
> 
> You can do that, or you can use Object.Attach() to reattach the specific control with a specific prefix.

Using Object.Attach() effectively removes that control from the group I had it in. Which is not what I want.

Regardless, I think I now understand that an object can use only one prefix (for its event handler name), and adding a Group 
property essentially overrides the prefix based on its name. So, I can either test its name in the shared prefix event handler, 
or remove it from the group and let it have its own event handlers.


-- 
Lee



More information about the User mailing list