MouseTracker and Synchronisation

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

MouseTracker and Synchronisation

Christoph J. Bachinger
Hi all,
I have a problem with MouseTracker Subclass, Menus, setting instance
variables and process synchronisation.
First have a look in my MouseTracker subclass method. I read out a flag
its initialy set to 0. The menu command change it to 1. But here I like
to reakt depending on the flag

But looking at the debugger at the halt, the value is still 0.
Debugging over the second
        save := self target initiator window trackingFlag.
the value is 1 as supposed.

onRightButtonReleased: aMouseEvent
        "The right mouse button has been released. Open a Menu, check a flag
set by the menu command in the instance variable of my Shell window.
Do something depending on the flag contents"


        | save |
        self target menuShowAt: aMouseEvent position.
        "self target initiator window is the path to my Shellwindow"
        "trackingFlag - get method vor instance variable trackingFlag"
        save := self target initiator window trackingFlag.
self halt.
        save := self target initiator window trackingFlag.
        ^nil

My Explanation is starting the Menu is asynchron to the mouse tracker.
The Menu command works in the Shellwindow context, and has lower
priority as the mouse tracker context. But how to solve the Problem.

It would be quiet easier to have the Menu command directed to my
MouseTracker instance or to the MouseTracker target instance but in
Dolphin I can't see the way to do Menu command redirection.


Any Ideas
thanks Christoph


Reply | Threaded
Open this post in threaded view
|

Re: MouseTracker and Synchronisation

Blair McGlashan-3
"Christoph J. Bachinger" <[hidden email]> wrote in message
news:[hidden email]...

> Hi all,
> I have a problem with MouseTracker Subclass, Menus, setting instance
> variables and process synchronisation.
> First have a look in my MouseTracker subclass method. I read out a flag
> its initialy set to 0. The menu command change it to 1. But here I like
> to reakt depending on the flag
>
> But looking at the debugger at the halt, the value is still 0.
> Debugging over the second
> save := self target initiator window trackingFlag.
> the value is 1 as supposed.
> ... [snip]...
> My Explanation is starting the Menu is asynchron to the mouse tracker.
>...

I'm not sure I fully understand your posting, but there is a simpler
explanation. Commands in Dolphin (mostly) originate from WM_COMMAND
messages. The Windows TrackPopupMenu() function used to show context menus
does not send a WM_COMMAND until after it has returned (probably it "posts"
it to the queue), so your command handler will not have been run by the time
you check the flag. The reason things are different after the halt is that
this allows further messages from the queue to be processed, including the
WM_COMMAND posted there to action the menu command. Windows is an event
driven system, so I'm afraid you can't assume that displaying a menu and
actioning the command selected by the user is an atomic operation that has
completed when the API call returns.

In order to recommend your best course of action I think we would need to
know a bit more about what you are trying to achieve. My initial reaction
would be that setting a flag that you later test is a "code smell" that
indicates you may be a better way to approach the problem.

Regards

Blair


Reply | Threaded
Open this post in threaded view
|

Re: MouseTracker and Synchronisation

Christoph J. Bachinger
Hi Blair

> I'm not sure I fully understand your posting, but there is a simpler
> explanation. Commands in Dolphin (mostly) originate from WM_COMMAND
> messages. The Windows TrackPopupMenu() function used to show context menus
> does not send a WM_COMMAND until after it has returned (probably it "posts"
> it to the queue), so your command handler will not have been run by the time
> you check the flag. The reason things are different after the halt is that
> this allows further messages from the queue to be processed, including the
> WM_COMMAND posted there to action the menu command. Windows is an event
> driven system, so I'm afraid you can't assume that displaying a menu and
> actioning the command selected by the user is an atomic operation that has
> completed when the API call returns.

Thanks this increases my knowledge about dolphin and windows.

> In order to recommend your best course of action I think we would need to
> know a bit more about what you are trying to achieve. My initial reaction
> would be that setting a flag that you later test is a "code smell" that
> indicates you may be a better way to approach the problem.

You are right this is more a test to see how to port my application from
VSE to Dolphin. What I realy need is a modal Menu. But further Testing
gave me some Ideas. So lets dig again :).

Thanks for your answer
Christoph