How to move mouse like the IDE

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

How to move mouse like the IDE

Post by atostaine »

I have this form where a user can rearrange the order of the labels. If the user presses the up or down button how do I make the mouse pointer follow it? The IDE does it when working with Layout Rows. I can move the focus to each button but that doesn't move the pointer.
fcolumns2.png
fcolumns2.png (20.86 KiB) Viewed 39208 times
This is how the rows look. The mouse cursor will follow you if click up or down
rows.png
rows.png (17.43 KiB) Viewed 39208 times
Thanks for any help
Art Tostaine
davidbalansa
Posts: 92
Joined: Mon Feb 01, 2016 10:08 am

Re: How to move mouse like the IDE

Post by davidbalansa »

Hi Art

I know this doesn't help much, but might give some ideas. I found that you can get the mouse position using the #sys_mouse.HorPosition and #sys_mouse.VerPosition unfortunately you can't set these properties.

David
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: How to move mouse like the IDE

Post by atostaine »

Thanks David. Everyone always says the IDE is written using LANSA but they still haven't convinced me. If I can get an answer to this that would help

Art
Art Tostaine
User avatar
MarcusLancaster
Posts: 32
Joined: Tue Nov 24, 2015 9:20 pm

Re: How to move mouse like the IDE

Post by MarcusLancaster »

Hi Art

Its been a while, but I wonder if you found a solution to this... I have a very similar requirement (moving entries up and down a list).

At V15 #sys_mouse hor/verposition are still read only.

Cheers for now.

Marcus.
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: How to move mouse like the IDE

Post by atostaine »

No I abandoned that idea. Sorry.
Art Tostaine
User avatar
Dino
Posts: 472
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Re: How to move mouse like the IDE

Post by Dino »

Why not to use drag and drop for that? much more simpler and popular this days.

There is an example provided in VL, form XDEMO_19 "Simple Drag and Drop"

this will be reduced to work with just one list:

Code: Select all

Function Options(*Direct)
Begin_Com Role(*EXTENDS #PRIM_FORM) Caption('Drag and Drop') Height(450) Left(246) Top(213) Width(779) ClientWidth(763) ClientHeight(411) Theme(#xDemoTheme)

Define_Com Class(#PRIM_TRVW) Name(#ListofLabels) ColumnButtonHeight(19) ComponentVersion(2) DisplayPosition(1) Height(378) KeyboardPositioning(SortColumn) Left(0) Parent(#COM_OWNER) TabPosition(1) Top(33) Width(380) LinesAtRoot(False) ViewStyle(UnLevelled) SelectionStyle(Multiple) FullRowSelect(True) DragStyle(Automatic) ColumnHeaders(False)
Define_Com Class(#PRIM_TVCL) Name(#TreeViewColumn) DisplayPosition(1) Level(1) Parent(#ListofLabels) Source(#xDemoCaption) Width(62) WidthType(Remainder)

Define_Com Class(#xDemoDragandDropImage) Name(#DragImage)

Evtroutine Handling(#Com_owner.CreateInstance)
Begin_Loop To(10)
#xDemoCaption := ("Left &1").Substitute( (#ListofLabels.Items.ItemCount + 1).AsString )
Add_Entry To_List(#ListofLabels)
End_Loop
Endroutine

Evtroutine Handling(#ListofLabels.StartDrag) Com_Sender(#Sender) Continue(#Continue) Payload(#Payload) DragList(#DragList)
#Payload <= #Com_owner.GetSelectedItems( #Sender )
#Continue := (#Payload *As #Prim_acol<#prim_tvit>).ItemCount > 0
#DragList.DragListStyle := Popup
#DragList.DragPopup <= #DragImage
#DragImage.DragCaption := (#Payload *As #Prim_acol<#prim_tvit>).ItemCount.AsString
#DragImage.DragImage <= #xImageFavorites32
Endroutine

Evtroutine Handling(#ListofLabels.DragOver) Com_Sender(#Sender) AcceptDrop(#Accept) Payload(#Payload) Source(#Source) ShowDropHilight(#DropHilight)
#DropHilight := True
#Accept := (#Payload *As #Prim_acol<#prim_tvit>).ItemCount > 0
Endroutine

Evtroutine Handling(#ListofLabels.DragDrop) Payload(#Payload) DragResult(#DragResult) Source(#Source)
#Com_owner.DoLeftDrop( #Source #ListofLabels.CurrentItem (#Payload *As #Prim_acol<#prim_tvit>) )
#DragResult := Accepted
Endroutine

Mthroutine Name(DoLeftDrop) Access(*Private)
Define_Map For(*Input) Class(#Prim_objt) Name(#Source) Pass(*By_Reference)
Define_Map For(*Input) Class(#Prim_tvit) Name(#DropItem) Pass(*By_Reference)
Define_Map For(*Input) Class(#Prim_acol<#prim_tvit>) Name(#Payload) Pass(*By_Reference)

For Each(#Item) In(#Payload)
If (#DropItem *Is *null)
#Item.Position := #ListofLabels.Items.ItemCount
Else
#Item.Position := #DropItem.Position
Endif
Endfor
Endroutine

Mthroutine Name(GetSelectedItems) Access(*Private)
Define_Map For(*Input) Class(#Prim_trvw) Name(#Tree) Pass(*By_Reference)
Define_Map For(*Result) Class(#Prim_acol<#prim_tvit>) Name(#Result) Pass(*By_Reference)

#Result <= *New #Prim_acol<#prim_tvit>
For Each(#Item) In(#Tree.Items)
Continue If(*Not #Item.Selected)
#Result.Insert( #Item )
Endfor
Endroutine
End_Com
User avatar
MarcusLancaster
Posts: 32
Joined: Tue Nov 24, 2015 9:20 pm

Re: How to move mouse like the IDE

Post by MarcusLancaster »

Thanks for the code snip Dino. Yep Drag and Drop is certainly an option I've considered, and have used that technique in the past on several occasions, but much like Art I was looking at the layout manager tool in the IDE and was wondering how mouse positioning in that scenario was accomplished, and if there had been any progress since the original post. Was just curious really.
User avatar
Dino
Posts: 472
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Re: How to move mouse like the IDE

Post by Dino »

This was a tricky question but fun. Seems that if you are using a grid, you cannot change the focus when you are focused in an item, triggering an event didn't helped either, so I just started a timer and the timer do the positioning in the other row afterwards. works pretty good.
if you use a tree or list instead of a grid, then the problem was handling the buttons events, didn't bother with that, just used the grid.

Code: Select all

Function Options(*Direct)
Begin_Com Role(*EXTENDS #PRIM_FORM) ClientWidth(644) ClientHeight(484) ComponentVersion(2) Left(836) Top(275)
Def_List Name(#savelist) Fields(#STD_TEXT) Type(*Working) Entrys(1)

Define_Com Class(#PRIM_GRID) Name(#Grid1) CaptionNoBlankLines(True) ColumnScroll(False) ComponentVersion(1) DisplayPosition(1) Left(31) Parent(#COM_OWNER) ShowSelection(True) ShowSelectionHilight(False) ShowSortArrow(True) TabPosition(1) Top(27) Height(398) Width(370) DragStyle(Automatic) ColumnButtonHeight(15) RowHeight(23) SelectionStyle(WholeRow)
Define_Com Class(#PRIM_GDCL) Name(#GridColumn1) DisplayPosition(1) Parent(#Grid1) Source(#STD_TEXT) Width(53)
Define_Com Class(#PRIM_GDCL) Name(#GridColumn2) DisplayPosition(2) Parent(#Grid1) Source(#butup) DisplayAppearance(Image) UsePicklist(True) EditAppearance(Image) CaptionType(ColumnHeadings) Width(12) ColumnAlign(Center) ReadOnly(False)
Define_Com Class(#PRIM_GDCL) Name(#GridColumn3) DisplayPosition(3) Parent(#Grid1) Source(#butdown) UsePicklist(True) CaptionType(ColumnHeadings) ColumnAlign(Center) Width(14) ReadOnly(False)

Define_Com Class(#PRIM_TIMR) Name(#Timer1) Startup(Manual) Interval(10)

Evtroutine Handling(#com_owner.CreateInstance)
#Grid1 := *DEFAULT
Begin_Loop To(10)
#STD_TEXT := ("Label &1").Substitute( (#Grid1.Items.ItemCount + 1).AsString )
Add_Entry To_List(#Grid1)
End_Loop
Endroutine

Evtroutine Handling(#GridColumn2.GotFocus) Options(*NOCLEARMESSAGES *NOCLEARERRORS)
Inz_List Named(#savelist)
#std_num := #Grid1.CurrentItem.Entry
If (#std_num > 1)
Dlt_Entry Number(#std_num) From_List(#Grid1)
Add_Entry To_List(#Grid1) After((#std_num - 2))
Endif
#std_num -= 1
#Timer1.Start
Endroutine

Evtroutine Handling(#GridColumn3.GotFocus) Options(*NOCLEARMESSAGES *NOCLEARERRORS)
Inz_List Named(#savelist)
#std_num := #Grid1.CurrentItem.Entry
If (#std_num < #Grid1.Entries)
Dlt_Entry Number(#std_num) From_List(#Grid1)
Add_Entry To_List(#Grid1) After(#std_num)
Endif
#std_num += 1
#Timer1.Start
Endroutine

Evtroutine Handling(#Timer1.Tick) Options(*NOCLEARMESSAGES *NOCLEARERRORS)
Get_Entry Number(#std_num) From_List(#Grid1)
#Grid1.CurrentItem.Focus #Grid1.CurrentItem.Selected #GridColumn1.Focus := True
#Timer1.Stop
Endroutine
End_Com
upanddown.jpg
upanddown.jpg (59.69 KiB) Viewed 37132 times
QuickExport20211026112944_upanddown.zip
(15.93 KiB) Downloaded 2560 times
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: How to move mouse like the IDE

Post by atostaine »

V14 latest EPC's my pointer isn't moving?
Art Tostaine
User avatar
Dino
Posts: 472
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Re: How to move mouse like the IDE

Post by Dino »

my mistake, forgot about the initial question regarding to move the mouse pointer. I think there is an activex that can access that windows function to set the mouse position in screen (I remember playing with that using iot with mouse.h library), but at the end, if you move programmatically the mouse position in the screen (and not the physical mouse), the user could ran out of mouse pad or have to reposition his hand/mouse to adjust to the running pointer... besides all the potential security issues (not just move, but click etc).

maybe the correct solution here is to request an enhancement to have a property like "move mouse pointer to element when selected/focused" checkbox... still kind of strange thing to have when most applications today don't do that. most move just the cursor to the default first focused element in the screen, but not the mouse. I did notice that in the layout, prefer the drag a row better.
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: How to move mouse like the IDE

Post by atostaine »

My question came about because of they way the ide does it. As I said before everyone at the old lansa would tell you the ide is written using lansa. There are certainly parts that are doable but so many things just aren’t possible.
Art Tostaine
Ingmar
Posts: 5
Joined: Mon Aug 29, 2016 4:45 pm

Re: How to move mouse like the IDE

Post by Ingmar »

Big parts of the IDE ARE written in LANSA. Not all though... Some bits are C++.

The magic moving mouse pointer was a bit of a strange hack from C++ that you can't do in RDML.

Very questionable UX though.... That you don't see it anywhere else should be telling.
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: How to move mouse like the IDE

Post by atostaine »

Ingmar: Is the text editor written in LANSA?

Art
Art Tostaine
Post Reply