About Monkey 2 › Forums › Monkey 2 Programming Help › How to catch drag & drop views?
This topic contains 4 replies, has 2 voices, and was last updated by
nerobot 2 years, 7 months ago.
-
AuthorPosts
-
August 27, 2016 at 6:18 pm #3511
I need to catch MouseDown on one view (1) and MouseUp on other view (2).
Then decide – what to do (or nothing) according with view1 and view2.
Have ideas – How ?
August 27, 2016 at 8:27 pm #3513You currently can’t (easily) – MouseDown ‘captures’ a view so that all successive mouse events until the next MouseDown are sent to the same view.
There’s a hidden method in View called ‘FindViewAtWindowPoint’ that could be used to help here – you’d need to transform the mouse location to ‘null’ (ie: window coords) and then pass this to ‘FindViewAt…’ – but there really needs to be a better way to do this.
August 27, 2016 at 8:52 pm #3514Something like this might work:
Monkey1234567891011121314151617181920Method OnMouseEvent( event:MouseEvent ) OverrideSelect event.TypeCase EventType.MouseDown'Begin drag...Case EventType.MouseUp'End drag...find drop view.Local point:=TransformPointToView( event.Location,Null )Local dropView:=Window.FindViewAtWindowPoint( point )If dropView'dropped on dropViewEndifEndEndLike I say, FindViewAtWindowPoint is technically ‘hidden’ right now, but we need some way to do this so have a play and let me know what you need!
August 29, 2016 at 11:16 am #3537I tried it, and dropView isn’t null, but how to check type of this view to debug? and type of any variable?
If I up mouse at TextVew and check it with
Monkey1Local tv := Cast<TextView>(droppedView)then ‘tv’ is null.
And what about App.MouseView property?
UPD: I can’t catch MouseUp for MainWindow because event was eaten by some child.
Thanks for App.MouseEventFilter += OnMouseEventFilter.
August 30, 2016 at 5:02 am #3546So,
1.
Local point:=TransformPointToView( event.Location,Null )
and event.Location is the same position.
Also, this position is relative to view which mouse is over.
2.
dropView := FindViewAtWindowPoint(point) – isn’t null, but I don’t know what is it. I press mouse on TreeView, then get that^ dropView and check it via
Monkey123Local tree := Cast<TreeView>(dropView)Print "is tree: "+String(tree<>Null)' output> is tree: 0 <-- WHY?Probably, FindViewAtWindowPoint expecting of global position but we put local. Don’t know how to make it global.
3.
event.View property – not null but not my TreeView. when it assigning?
4.
When I drag mouse to TextField and up it – don’t see MouseUp event inside TextField.
5.
MouseEnter / MouseLeave – doesn’t works.
-
AuthorPosts
You must be logged in to reply to this topic.