[Gambas-user] Mouse X & Y reporting...

Bruce Steers bsteers4 at gmail.com
Wed Nov 15 18:24:37 CET 2023


.Expand = True

The IconView and TextArea have Expand = True

The main form has Arrangement = Arrange.Vertical
Then a Label,
Then the IconView
and TextArea

It would be better with the IconView and TextArea being inside a Splitter
but is only a tester prog

Hope the TextArea.CursorFrom() code is of use to you :)

This post kinda took a life of it's own but to stay on the initial topic
remember in the drop event mouse X/Y of the object dropped onto can be
found with Drag.X and Drag.Y
Mouse.X and Mouse.Y should only be used in an objects Mouse events not a
Drop event.

:)
Happy coding
BruceS



BruceS

On Wed, 15 Nov 2023 at 15:56, sbungay <sbungay at smartsonsite.com> wrote:

> Stupid question: What mechanism is making the components in the example
> automatically go full width of the form?
>
> On 2023-11-14 12:44, Bruce Steers wrote:
> > I added a CursorFrom() method to TextArea in the attached project.
> >
> > If you drop the TextArea.class file into your project then it adds to
> > all TextArea controls the method..
> >
> > TextArea1.CursorFrom(X as Integer, Y As Integer) As Integer
> >
> > I called it CursorFrom() because it compliments CursorAt()
> >
> > Should work with any font.
> >
> > The attached project has a test prog that lists $HOME in an IconView,
> > dragging files to the TextArea inserts filenames at drop position.
> >
> >
> > Respects
> > BruceS
> >
> >
> > On Mon, 13 Nov 2023 at 21:01, T Lee Davidson <t.lee.davidson at gmail.com
> > <mailto:t.lee.davidson at gmail.com>> wrote:
> >
> >     On 11/13/23 12:05, T Lee Davidson wrote:
> >      > I've tried with Tracking turned off (as it is not needed) and
> >     getting the Mouse.X/Y coordinates in the Drop event, but the
> >      > values are inconsistent.
> >
> >     Further, I've come up with simple Drop event code that I think
> >     /might/ work, but I cannot verify it because setting
> >     TextArea.Line crashes the program when using gb.gtk3. I can't test
> >     the algorithm with Qt either because no drag or drop events
> >     fire. With gb.qt5 it just, simply, works.
> >
> >     Note: This code requires the use of a monospace font for the
> TextArea.
> >     [code]
> >     Public Sub TextArea1_Drop()
> >
> >         TextArea1.Line = Min(TextArea1.Line, Int((Mouse.ScreenY -
> >     TextArea1.ScreenY) / TextArea1.Font.Height))
> >         TextArea1.Column = Min(TextArea1.Column, Int((Mouse.ScreenX -
> >     TextArea1.ScreenX) / TextArea1.Font.TextWidth(" ")))
> >
> >         TextArea1.Insert(Drag.Data)
> >
> >     End
> >     [/code]
> >
> >
> >     --
> >     Lee
> >
> >
> >     ----[ http://gambaswiki.org/wiki/doc/netiquette
> >     <http://gambaswiki.org/wiki/doc/netiquette> ]----
> >
> >
> >
> > ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
> --
> Stephen A. Bungay, Prop.
> Smarts On Site
> Managed Information Systems & Support Services
> 705.734.0597
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20231115/b681b4b1/attachment-0001.htm>


More information about the User mailing list