#main.draw, "drawbmp aBitmap ";bmpx;" ";bmpy wait '---------------- [reset] q=0 wait '----------------- [quitmenu] close #main end
This code works, but i want to use it whitout : leftButtonMove. So only : mouseMove
Why ? When i using a touchscreen even the "push" for leftButtonMove works, but is will be nicer without it. (example open a resized window with remote desktop on a mobile)
Then i have to notice when the mouseMove is ended.
mouseMove works. The picture will follow your finger. (added) When you don''t touch the screen anymore, the picture have to be on the same place. The second time, when you 'll touch the screen (doesn't matter where) and move the picture, the picture musn't return to the new place of your finger.
It is possible in my first example, but with press the touchscreen. (actived button and move) When you touch the screen again on a other place there is a big different between the last x , y and the new one. I did solved that with q en remove this different when started a new touch/move.
It have to be possible without that and only touch without push leftbutton on the screen.
When I run your most recent code on my touch screen system it isn't getting mouseMove at all. It is being driven by leftButtonMove. It IS driven by mouseMove when I use the mouse, but using my finger mouseMove never kicks in. I never see it listed while the graphic is moving under my finger. Perhaps our systems differ.
Using the leftButtonMove allows me to move the graphic with the mouse or my finger. Using the mouse I get the cursor crosshair as feedback about what is going on. Using my finger the system does not show the cursor because it is hidden by my finger. To get the rightButtonDown I press and hold my finger and it returns the graphic to the last known position.
Try this and tell me what still is not behaving correctly for you.
You're right. It doesn't work on a windows laptop with touchscreen. Not even in tabletmodus.
But it does work on a mobile (android) with remote desktop with a little window in the left corner on a window home pc.
My first code and your code works. You can push the mobile screen and move the picture. The second, i can move it to a other place.
Now i try to move the picture in this situation without pushing the screen and us only the mouseMove function. It works, the picture moved, but i can't recognize the end of the mousemove. The second time, the picture move to the new startposition.
I don’t think you will. You need a mouseStop event and there isn’t one. You might use a timer to check if the graphic is moving but it might be clunky and you would need to time it right so it won’t react to slight hesitations.
You also need a starting event, if you just start mouseMove the graphic will move all the time, surely the graphic needs clicked on to start the mouseMove process?
Not sure how practical this will be. It starts when it first sees a mouseMove, it stops when the mouse has not moved for 500ms. You may still find it difficult to stop the process as any mouse movement starts it all over again. Cant test it so see how it works for you.
nomainwin WindowWidth = 390 'venster breedte WindowHeight = 660 '660 'venster hoogt graphicbox #main.draw, 10, 45, 280, 350 open "Move picture" for window as #main #main "trapclose [quitmenu]" '
I would try to just issue a "when mouseMove" statement.
When the mouse is moving? when it comes to a stop? when it starts moving? I timed it.
Bottom line is that while my code works it is not a solution that will fit many real life problems.
Any screen based, mouse or finger interaction is a conversation that typically must have a beginning and an end. it must be acknowledged or understood by both parties. Windows hardware, in a Windows environment, issues a strict series of events like leftMouseDown, leftMouseMove and leftMouseUp that all happen in a predictable sequence. Sver is playing air guitar right now. He waves his hand and it works which is great, but it is all that it can do. I prefer predictable sequences.
it is amazing to think that his Android phone is reading his finger, sending a stream of Windows mouseMove messages over the telephone network, injected those to Windows which feeds them to Liberty. Amazing that it actually works, no strike that, its a holiday miracle!
we should all experiment more with what can be done remotely.
Running Win11 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz 2.42 GHz 64bit with 32Gb ram
Post by Brandon Parker on Dec 20, 2019 18:43:24 GMT -5
This bit of code might be of interest for mouse functions. It has absolutely nothing to do with what you are doing, but the mouse functions and associated structure I used might help you determine the best method to do it on your end.
If I understand correctly, you would be interested mostly in startDrag, mouseDrag, and stopDrag functions in my code below as well as the drawingValues structure. I used these methods to draw a rubber-band rectangle for user selection and grabbing the coordinates to be snipped.
Struct drawingValues, start As boolean, _ X As long, _ Y As long, _ xPrior As long, _ yPrior As long, _ xNow As long, _ yNow As long
GraphicBox #window.gbox, 2, 2, gboxWidth, gboxHeight GraphicBox #window.gbox2, 500, 2, gboxWidth, gboxHeight Button #window.btnClear2, "Clear", btnClear2, UL, 916, 471, 75, 30 Open "Drag-A-Box" For Window_NF As #window #window "TrapClose quit"
[LoadBitmap] FileDialog "Choose a Bitmap to Open ...", "*.bmp", openBitmap$ If Not(Lower$(Right$(openBitmap$, 4)) = ".bmp") Then Confirm "Warning!" + chr$(13) + "The file you selected is not a .bmp file." + chr$(13) + chr$(10) + _ "Would you like to open a .bmp file?"; answer$ If Lower$(answer$) = "yes" Then GoTo [LoadBitmap] Else LoadBMP "BackgroundBMP", openBitmap$ End If If isBitMap("BackgroundBMP") Then #window.gbox "Down; Fill White; DrawBMP BackgroundBMP 0 0" Else #window.gbox "Down; Fill Black; Color White; BackColor White; Home; CircleFilled 250; Color Black; BackColor Black; CircleFilled 125" End If #window.gbox "Flush initialBackground; Color Red" #window.gbox "When leftButtonDown startDrag; When leftButtonMove mouseDrag; When leftButtonUp stopDrag"
'Do the next one just in case the user hits the right mouse 'button while dragging. The program will operate the same 'as if the left mouse was clicked; otherwise the box would be stuck. #window.gbox "When rightButtonUp stopDrag"
Sub stopDrag handle$, MouseX, MouseY If (drawingValues.xPrior.struct <> drawingValues.X.struct) And (drawingValues.yPrior.struct <> drawingValues.Y.struct) Then If drawingValues.xNow.struct < drawingValues.X.struct Then tempX = drawingValues.xNow.struct drawingValues.xNow.struct = drawingValues.X.struct drawingValues.X.struct = tempX If drawingValues.X.struct < 0 Then drawingValues.X.struct = -1 End If If drawingValues.xNow.struct > gboxWidth Then drawingValues.xNow.struct = gboxWidth End If If drawingValues.yNow.struct < drawingValues.Y.struct Then tempY = drawingValues.yNow.struct drawingValues.yNow.struct = drawingValues.Y.struct drawingValues.Y.struct = tempY If drawingValues.Y.struct < 0 Then drawingValues.Y.struct = -1 End If If drawingValues.yNow.struct > gboxHeight Then drawingValues.yNow.struct = gboxHeight End If #handle$ "Rule XOR; Box "; drawingValues.xPrior.struct; " "; drawingValues.yPrior.struct #handle$ "Rule OVER; Discard" If ((drawingValues.xNow.struct - drawingValues.X.struct - 3) >= 0) And ((drawingValues.yNow.struct - drawingValues.Y.struct - 3) >= 0) Then #handle$ "GetBMP BoxSelection ";(drawingValues.X.struct + 1);" ";(drawingValues.Y.struct + 1);" ";_ (drawingValues.xNow.struct - drawingValues.X.struct - 3); " ";_ (drawingValues.yNow.struct - drawingValues.Y.struct - 3) End If drawingValues.X.struct = 0 drawingValues.Y.struct = 0 drawingValues.xPrior.struct = 0 drawingValues.xNow.struct = 0 drawingValues.yPrior.struct = 0 drawingValues.yNow.struct = 0 End If End Sub
Sub pasteSelection handle$, MouseX, MouseY If Not(isBitMap("BoxSelection")) Then Exit Sub #handle$ "Down; DrawBMP BoxSelection ";MouseX;" ";MouseY #handle$ "Flush drawnBox; Up" End Sub
'----------------- [quitmenu] close #main end '-------------------------------------------------------------- function CursorPos$(handle) Calldll #user32, "GetCursorPos",_ point as struct,_ result as long Calldll #user32, "ScreenToClient",_ handle As Ulong,_ point As struct,_ result as long x = point.x.struct y = point.y.struct ' CursorPos$=x; ",";y end function
Different code
When there is no different between old en new x or/and y, the mouse move stopped. When there is different between old en new x or/and y, the mouse move started.
I'am testing which code is the quickest. (dependend of 4G, how much kb drawing) With 5G, it 'll be better.