[Gambas-user] I added "Paste at mouse position" to my GUI designer :)

Bruce Steers bsteers4 at gmail.com
Tue Feb 13 17:24:43 CET 2024


I just added a couple of really useful menu items to FForm.class in the IDE
(the gui designer)
Maybe you could consider the same Ben as it's pretty darn useful I think :)

Now the form designer popup menu also has a "Paste special" just like the
text editor but the .form paste special has these 2 items...

Paste exactly at mouse
 This removes the #BOUNDS regardless of the copy method and sets the Move
or MoveScaled position as absolute to paste exactly at the mouse position
when the right mouse was clicked.

Nearest space to mouse
 This makes sure the #BOUNDS header is there so FindFreeSpace is done
regardless of the copy method and just makes the FindFreeSpace method start
from the mouse position instead of 0,0

The menu hides itself if the user has left clicked the main menu, it only
shows if right clicked in the designer.
(and hides if there's nothing to paste of course)
most of the function is here:
https://gitlab.com/bsteers4/gambas/-/blob/748d4cada19260274d728cbeee1aa5c7b7f69861/app/src/gambas3/.src/Editor/Form/FForm.class#L269

To FForm.class I added Private $iContainerMX and $iContainerMY that get the
Mouse X Y when a container or control are clicked (if it's a control then
the Parent is used). ($MX - hParent.Control.ScreenX seemed to be unreliable)

I use these in the FromText() method if a mouse paste has been used to
change #BOUNDS: or Move/MoveScaled of the paste.

I modified the PasteSelection method to make PutSelection() iIndex argument
be -2 (find space) or -3 (absolute) to enable mouse pasting as
PasteSelection method does not use the Index argument for PutSelection and
PutSelection only currently uses it if it's >=0


Now that's super useful. :D
Now I can copy things and paste them either exactly or roughly where i want
them :)
This will come in especially handy when pasting into a Frame where it
always put's things at the top in the title line because a paste does not
account for the frames top title line above the inner container but just
uses the outer container.

Or a Scrollview where i have space above but want it pasted below.

Gambas rocks :)

Respects
BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20240213/925db567/attachment.htm>


More information about the User mailing list