Hi Oliver,
I did not see this on the user list, maybe some glitch at SourceForge?
Look below, I'll try to answer.
Oh - I just read through it. This is a problem I knew you were going to
have, unless you adjusted your thinking ...
Go down to your original post
On Fri, Jan 6, 2012 at 8:00 AM, Oliver Sims <
oliver.s...@simsassociates.co.uk> wrote:
> **
> Did you get this one Mark? I sent it to the list but I don't think I've
> seen it distributed back to me.
>
> Thx,
> Oliver
>
> PS - the two dialogs referred to are running in the same process - that
> is, I have a single "startup" exec like in the user guide exercises.
>
> PPS - I said:
> > Now, with the mouse not over either dialog, I press the left mouse
> button I then repeat the above but with the left button pressed.
> > Neither dialog seems to detect a mouse entry or move or hover - or
> anything.
> In addition, when I pick up from the source dialog and drag over the
> target dialog, I do not get any method fired in the target dialog.
>
>
> ------------------------------
> *From:* Oliver Sims [mailto:oliver.s...@simsassociates.co.uk]
> *Sent:* 05 January 2012 18:06
> *To:* 'oorexx-users-ow...@lists.sourceforge.net'
> *Subject:* ooDialog - Mouses Again - Detecting entry
>
> So far so good. But another question:
>
> I'm now trying to drag-drop between two dialogs - one "source" and one
> "target".
> So, I have two mouse-enabled dialogs. I start them both. They are not
> overlapped on the screen. My mouse is not on either of them when they are
> started.
> I now move the mouse onto and then off one of the dialogs, and then onto
> and off the other (with no mouse buttons pressed).
> Both dialogs detect a mouse move (the onMouseMove method is fired) and a
> mouse leave (the onMouseLeave method is fired).
>
>
Okay, fine that is as expected.
>
>
> Now, with the mouse not over either dialog, I press the left mouse button
> I then repeat the above but with the left button pressed.
> Neither dialog seems to detect a mouse entry or move or hover - or
> anything.
>
>
Yes, that is to be expected. Here is where you need to adjust your
thinking. *Mouse messages are sent to the window the mouse is over.*
So, when you press the left button down, that message is sent to the window
the mouse is over. Which as you say, is *not* one of your windows. You
can not detect that. The window it is over, gets the message, most likely
does a DragDetect(), gets back true, and captures the mouse. This is for
sure what happens if the mouse is over the DeskTop window, which is
drag-enabled.
As the mouse moves over your dialog windows, no mouse messages are sent to
your windows, they are sent to the window that has captured the mouse. The
DeskTop window most likely from your description (see my final remarks #1.)
The window that captured the mouse is not going to release the mouse
capture until it gets the left button up message, (or to be technically
correct, the user presses the escape key.)
To do drag and drop between your two dialogs, (at this point with ooDialog,
see my final remarks #2,) you are going to have to use the technique I
demonstrate in the dragNdrop.rex example. You just need to adjust the code
to drag from one dialog window to another dialog window, rather than from
one list view to another list view.
Here's the technique: You set both dialogs to detect left mouse button
down, mouse move, and left mouse button up.
In the button down event handler, you: determine if the user is starting a
drag operation (dragDetect), determine if the mouse point in you dialog is
over something draggable, if so capture the mouse.
Now in your left mouse button up handler, you determine if you are in the
middle of a dragging operation, if so you take the mouse position, which is
going to be in client co-ordinates of the dialog where you captured the
mouse and determine where exactly the user let go of the left mouse
button. If that point is at a droppable location, you finish up with the
drop.
In you mouse move handler, you check if you are in a drag operation, if not
you most likely do nothing. If you are, the mouse position is going to be
in client coordinates of the dialog where you captured the mouse. You
determine if that position is over a droppable area, if not you set the
cursor to your 'no drop' cursor. If yes, you set it to the 'drop okay'
cursor.
Play around with the dragNdrop.rex example a little. You will see that if
you hold down the left mouse button and it is not over a list view item in
one of the list views of the program, nothing happens. If you are over a
list view item, the cursor changes to the 'no drop' cursor. (Because the
program does not allow you to drop the item back into the same list view.)
You can move the cursor *anywhere* on the screen and cursor remains either
the 'no drop' or the 'drop ok' cursor - until you release the button. You
might want to print out the mouse position in your mouse move handler to
get an idea of the point values you will be getting.
Basically what you will do in your program, (provided that you only allow
dropping on your second dialog,) is keep the cursor the 'no drop' cursor
until you determine the mouse is over the second dialog.
My dragNdrop.rex program has me convinced this will work, but I haven't
actually tried it between two dialogs. There may be a few wrinkles that
need to be straightened out from my description above, but I think it will
work.
>
>
> My question is: how can I get a dialog to detect a mouse when (a) the left
> button is down on entry and
>
mouse = .Mouse~new(obj)
mouse~isButtonDown('LEFT')
But, for your program, this is not going to help you.
> (b) when the mouse is over a dialog that was NOT the dialog over which I
> pressed the left button to begin the drag.
>
This is going to be dependent on where the mouse was when you pressed the
left button to begin the drag. *If* the mouse was not over one of your
dialogs, you are not going to be able to, most likely, as explained above.
If the mouse is over one of you dialogs, you will *have* to capture the
mouse and start processing the mouse move messages. For each move, you map
the mouse position to points over your 'other' dialog and determine if that
position is over the dialog or not. The dragNdrop.rex example shows how to
do that.
Final remarks:
1.) I say the desk top window most likely, because from your description
the mouse is captured by some window. The DeskTop window for sure captures
the mouse. However, if the mouse is over some other window, that does not
capture the mouse, you *should* get the mouse messages. You can probably
test that your self by starting up some ooDialog dialog that is in a
different process than your drag and drop dialogs. Since that other dialog
will not do a mouse capture (be sure you are on the dialog background and
not a dialog control) you should see the mouse messages.
The point though is that this is not going to be reliable - you never know
where the user may decide to press the mouse button down. You can only
detect this reliably when the mouse is over a window you own.
2.) Much of the drag and drop you see in Windows is implemented using COM.
This is the drag and drop you see in Windows Explorer, or the drag and drop
you see that is between two programs running in separate processes, maybe
even programs produced by different companies. I would like to implement
that, and can, but it is a lot of work. I won't be doing that for some
time, not the foreseeable future. What we have now, I believe, will work
fine inter-dialog, or dialog to dialog where the dialogs are controlled by,
that is, in the same ooDialog program.
You're likely to have more questions, so ask away.
--
Mark Miesfeld
------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual
desktops for less than the cost of PCs and save 60% on VDI infrastructure
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-users