Force a view to process events?

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

Force a view to process events?

Jeff M.
Is there a message I can send to a view to force it to process events?
For example, in C++, I'd just do something like this for my main loop:

void run()
{
    while(1) {
        if (PeekMessage(...)) {
            TranslateMessage(...);
            DispatchMessage(...);
        } else {
            /* Do something */
        }
    }
}

This is, of course, akin to an OnIdle. But, I'd like to not have the
loop code inside the view that I'm going to create. Instead, I'd like
to have an infinite loop that just once per iteration allows the view
to process events. If this were VB, it would look something like this:

while true
    ' Do something here
    DoEvents()
wend

I was hoping that there was something similar for the View class, so
that I could just have a loop doing typical stuff, and then send a
message to it (something like #processEvents). There are a few messages
that I've found, but none of them seem to do what I'd hoped (or I'm not
quite sure how to use them the way they are intended):

#performAction
#defaultWindowProcessing:

#performAction doesn't seem to do anything (at least what I was
hoping), and #defaultWindowProcessing takes an event as a parameter,
which I don't know how to get. I could just use the Win32 functions
(like my first example), but I was wondering if there was a... well...
more ST-ish way to do it? :-)

Thanks, and I'm sorry if this is super obvious and I just overlooked
it.

Jeff M.


Reply | Threaded
Open this post in threaded view
|

Re: Force a view to process events?

Ian Bartholomew-21
Jeff,

> Is there a message I can send to a view to force it to process events?

Can you give us some idea, in a general way, of what you are hoping to
achieve.  It sounds like you are trying to get involved in the low level
operations, it is quite uncommon (but certainly not unknown) to need to do
that.

Perhaps you need something as simple as a #sleep...

process := [[
    self doSomething.
    Processor sleep: 5] repeat] fork

Which would sleep the active process for 5 mS every loop, to allow
background processing to take place, until the process is terminated.

--
Ian

Use the Reply-To address to contact me (limited validity).
Mail sent to the From address is ignored.


Reply | Threaded
Open this post in threaded view
|

Re: Force a view to process events?

Andy Bower-3
In reply to this post by Jeff M.
Jeff,


> This is, of course, akin to an OnIdle. But, I'd like to not have the
> loop code inside the view that I'm going to create. Instead, I'd like
> to have an infinite loop that just once per iteration allows the view
> to process events. If this were VB, it would look something like this:
>
> while true
>     ' Do something here
>     DoEvents()
> wend
>

I think what you are looking for is:

SessionManager inputState pumpMessages.

Do a browse references for #pumpMessages to see how and where it is
used.

Best regards,

--
Andy Bower
Dolphin Support
www.object-arts.com


Reply | Threaded
Open this post in threaded view
|

Re: Force a view to process events?

Udo Schneider
In reply to this post by Jeff M.
Jeff M. wrote:
> while true
>     ' Do something here
>     DoEvents()
> wend
InputState (accessible via SessionManager current inputState) offers a
few methods which might help you:
#loopWhile:
#processDeferredActions
#pumpMessages

This might help you to implement the desired functionality or even show
you the "Dolphin-way" to do it.

CU,

Udo


Reply | Threaded
Open this post in threaded view
|

Re: Force a view to process events?

Chris Uppal-3
In reply to this post by Andy Bower-3
Jeff, Andy

> SessionManager inputState pumpMessages.
>
> Do a browse references for #pumpMessages to see how and where it is
> used.

And, more inportantly perhaps, how /rarely/ it is used ;-)

    -- chris


Reply | Threaded
Open this post in threaded view
|

Re: Force a view to process events?

Esteban A. Maringolo
In reply to this post by Jeff M.
Jeff M. escribió:

> This is, of course, akin to an OnIdle. But, I'd like to not have the
> loop code inside the view that I'm going to create. Instead, I'd like
> to have an infinite loop that just once per iteration allows the view
> to process events. If this were VB, it would look something like this:
>
> while true
>     ' Do something here
>     DoEvents()
> wend

Dolphin Smalltalk equivalence:
[true] whileTrue: [SessionManager inputState pumpMessages]

Regards,

--
Esteban.