A problem with the usage of queryCommand:

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

A problem with the usage of queryCommand:

Joseph Frippiat
The push buttons on my view are enabled or disabled in function of the
values of state variables in my model.  To do that, I use the
queryCommand method like this :

------->8------->8-------
myShell>>queryCommand: aCommandQuery
        "Private - "

        (#(#abort) identityIncludes: aCommandQuery command)
                ifTrue:
                        [aCommandQuery isEnabled: self model calling.
                        ^true].
        (#(#exitFromAnswering) identityIncludes: aCommandQuery command)
                ifTrue:
                        [aCommandQuery isEnabled: self model answering.
                        ^true].
        (#(#call #configure #returnToAnswering) identityIncludes: aCommandQuery
command)
                ifTrue:
                        [aCommandQuery isEnabled: (self model calling not and: [self model
answering not]).
                        ^true].
        ^super queryCommand: aCommandQuery
------->8------->8-------

If I click on a button and if the model changes the state variables fast
enough, the buttons are refreshed and all works fine.

If my model changes the state variables after a while the buttons are
not refreshed.  If I cover the view with another window and if I uncover
it, the buttons are refreshed.

How can I force automatically the refreshing of the view so that the
buttons "enabled/disabled state" reflects the model state variables ?

Thanks,

Joseph


Reply | Threaded
Open this post in threaded view
|

Re: A problem with the usage of queryCommand:

Schwab,Wilhelm K
Joseph,

> If I click on a button and if the model changes the state variables fast
> enough, the buttons are refreshed and all works fine.
>
> If my model changes the state variables after a while the buttons are
> not refreshed.  If I cover the view with another window and if I uncover
> it, the buttons are refreshed.
>
> How can I force automatically the refreshing of the view so that the
> buttons "enabled/disabled state" reflects the model state variables ?

Try #invalidateUserInterface.  FWIW, in the code that I recalled doing
something like this, I have the send queued as a deferred action.  There
are two likely explanations for that: (1) I moved the code from a
background thread and forgot to remove the queuing; (2) it was necessary
to get it to work.

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: A problem with the usage of queryCommand:

Joseph Frippiat-2
Bill Schwab a écrit :
> Try #invalidateUserInterface.

Bill,

it works!  I created a small test application and I used this method in
the presenter:

MyShell>>createSchematicWiring
        super createSchematicWiring.
        self model
                when: #var1Changed
                send: #invalidateUserInterface
                to: self.
        self model
                when: #var2Changed
                send: #invalidateUserInterface
                to: self

At the first time I didn't know where to put the #invalidateUserInterface .

Thanks,

Joseph