[Gambas-user] Does ListBox ''_MouseDown()" Event work ?
BB
adamnt42 at gmail.com
Sat Dec 9 15:30:29 CET 2023
On 10/12/23 12:19 am, Bruce Steers wrote:
>
>
> On Sat, 9 Dec 2023 at 10:51, Gianluigi <gradobag at gradobag.it
> <mailto:gradobag at gradobag.it>> wrote:
>
> Il 09/12/23 10:45, Claus Dietrich ha scritto:
>> >/Le 08/12/2023 à 14:06, T Lee Davidson a écrit : />/> On 12/7/23 20:13, vuott--- via User wrote: />/>> Hello, />/>> the ListBox ''_MouseDown()" Event does not work for me. />/>> />/>> />/>> [System] />/>> Gambas=3.18.90 38b49c0 (master) />/> [snip] />/> />/> The issue exists with v3.18.4 as well. Interestingly, a
>> double-click />/> triggers the MouseDown event with both Qt5 and GTK3. />/> />//>/Compound non-native controls usually eat some of the low-level
>> events. />//>/You should normally never try to handle low-level events on complex />/controls. />//>/Regards, />//>/-- />/Benoît Minisini. This reply made me curious and I would be
>> grateful if somebody can provide some background and help me to
>> understand: What are possible reasons that non-native controls
>> "eat some of the low evel events"? Why should I never try to use
>> events which are a documented capability of a control? Shall I
>> regard it as normal that I can only access an event if I add
>> additional code as proposed by Bruce? I am asking this, because I
>> program controls myself (beginner level) and so far didn't have
>> the experience, that events fail - unless I forgot to raise them.
>> Best regards Claus /
>
> Hi Claus,
>
> you're not the only one who was baffled by Benoit's response.
>
> We discussed this with other users of the Italian forum and like
> you we are all curious.
>
> With best regards
>
> Gianluigi
>
>
> It made perfect sense to me as I myself have written many compound
> controls. There is much excessive code needs to be added to make all
> compound controls trigger all standard control events.
>
> Like Benoit explained gambas unique controls (from gb.gui.base, and
> some gb.form) are made by using a container, maybe a panel, then
> various other controls placed inside.
>
> In order to make something like MouseDown trigger no matter where you
> click you have to make a MouseUp event for every added control inside
> the container.
>
> a ListBox for example is actually a gridview inside it's own container.
>
> internally the gridview gets its events inside the listbox.
> The listbox itself only has 3 events..
> Event Click
> Event Activate
> Event Select
>
> The Click event for example is not just the gridviews click event.
> the listbox creates a timer on the gridviews Change event and then
> triggers it's own Click event.
>
> Things to consider about you bafflement...
> there are many different gambas compound controls made with many
> different combinations of objects.
>
> the code would have to be filled with many lines like this..
>
> Public Sub IntrnalTextBox_MouseDown()
>
> Raise MouseDown
>
> End
>
> Public Sub IntrnalLabel_MouseDown()
>
> Raise MouseDown
>
> End
>
> Public Sub IntrnalPanel_MouseDown()
>
> Raise MouseDown
>
> End
>
> So imagine having that (and having to do that) for every gambas
> controls internal objects and for every standard event.
> that's going to be a lot of bloating.
>
>
> Possible solutions for you Ben....
>
> some sort of event , er , upstreamer, for want of a better word.
> a new property for controls, something like ContainerTriggers or something
> So if i set InternalLabel.ContainerTrigger = True it will auto try to..
> Object.Raise(Me._Container, sEventName)
> (you know what i mean)
>
> or..
> A way to hide all the events of Control.class from UserControl.class
> as they are not all really supported by the control.
> Because in the IDE if i type Public Sub ListBox1_ then i get a list
> of all Control.class events. even though only some of the events will
> actually do anything. and can be unexpected like the ListBox_MouseDown
> example that does actually fire for some reason with a double click.
>
> That might at least make things clearer for the programmer.
>
>
> Possible solutions for us..
> Understand there is a difference with a toolkit control and a gambas
> compound control. (i guess it should be documented better)
>
> As i previously mentioned all gambas compound controls have a way to
> access and Observe the events of the internal object should you want
> to do anything fancy.
> see Observer.class and Watcher.class (definately avoid using
> Object.Attach() as this will break stuff for sure)
>
> As Benoit mentioned there are risks with doing this as the control is
> using it's internal events as it needs to and if you have not studied
> the controls code you may interfere with it's internal workings.
> But if you study the controls code in gb.gui.base or gb.form or
> whatever then you can probably modify. auto-inheritance can be a good
> way to modify compound control events.
>
>
> Some food for thought. :)
>
> Respects
> BruceS
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
Apart from all the above, may I respectfully add the following.
As BruceS uses, the term "*compound controls*" are (fairly simple)
controls that are constructed using toolkit controls inside a container
of some sort. Further, as he states, the exposed aspects of those are
entirely up to the designer of that control as the "visible" control is
the container. However, this can be complicated by the use of the Proxy
property which thereby exposes the events of one of the contained
controls _or not_.
Notwithstanding that, compound controls can have valid reasons for not
exposing certain aspects of the inner controls. Here we have built many
custom controls that vary from simple to extremely complex in design and
structure. One in particular comes to mind is a specific data bound
combobox. The List and the data need to be protected from the inner
combobox Text property so that selections can be made using the drop
down list or by typing in a "part" of the list texts. Allowing access to
the inner control aspects could/would be dangerous to the valid use of
the control, so we have taken steps to ensure that they are not
available to inadvertent misuse by other coders.
ymmv and cheers
b
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20231210/118924ca/attachment-0001.htm>
More information about the User
mailing list