Presenters values depending on each other

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

Presenters values depending on each other

Sebastián Sastre
Hi all,

    I have 2 prices on anItem that depends on each other by some linear
equation.

    What I was asked to do, is that in the properties dialog of this item,
one can edit any of this two prices, and when changing one, the other has to
be refreshed to has it's corresponding value.

    So I can have the refreshed value on the model but do not see it in the
presenter.
I tried to do this with valueChanged but then I figure out that this event
implies more information than the idea on the presenter thats it's being
edited by the user, it also be another object. So I'm thinking about
onKeyPressed or onKeyReleased event but I don't have idea on how to know
when aKeyEvent is a number (from keyboard or numpad).

    Any clue?

Best regatds,


--
Sebastián Sastre
[hidden email]
www.seaswork.com.ar


Reply | Threaded
Open this post in threaded view
|

Re: Presenters values depending on each other

Yar Hwee Boon-3
On Wed, 1 Sep 2004 11:22:40 -0300, Sebastián Sastre  
<[hidden email]> wrote:

> Hi all,
>
>     I have 2 prices on anItem that depends on each other by some linear
> equation.
>
>     What I was asked to do, is that in the properties dialog of this  
> item,
> one can edit any of this two prices, and when changing one, the other  
> has to
> be refreshed to has it's corresponding value.
>
>     So I can have the refreshed value on the model but do not see it in  
> the
> presenter.
> I tried to do this with valueChanged but then I figure out that this  
> event
> implies more information than the idea on the presenter thats it's being
> edited by the user, it also be another object. So I'm thinking about
> onKeyPressed or onKeyReleased event but I don't have idea on how to know
> when aKeyEvent is a number (from keyboard or numpad).

Browse for #aspectTriggers:. There is an example in PersonalAccountShell.  
Assuming you are using the built-in text controls, you can set the  
#updatePerChar aspect to true?

--
Regards
Hwee Boon
MotionObj


Reply | Threaded
Open this post in threaded view
|

Re: Presenters values depending on each other

Sebastián Sastre
Yar,

    thanks for your answer.

   It could be an example of the situation I have, if you can edit Balance
and initial balance simultaneuosly (one changing by the users entry, and the
other by the model, and viceversa). So it's not exactly the problem I'm
bringing.

    regards,


--
Sebastián Sastre
[hidden email]
www.seaswork.com.ar

"Yar Hwee Boon" <[hidden email]> escribió en el mensaje
news:[hidden email]...

> On Wed, 1 Sep 2004 11:22:40 -0300, Sebastián Sastre
> <[hidden email]> wrote:
>
> > Hi all,
> >
> >     I have 2 prices on anItem that depends on each other by some linear
> > equation.
> >
> >     What I was asked to do, is that in the properties dialog of this
> > item,
> > one can edit any of this two prices, and when changing one, the other
> > has to
> > be refreshed to has it's corresponding value.
> >
> >     So I can have the refreshed value on the model but do not see it in
> > the
> > presenter.
> > I tried to do this with valueChanged but then I figure out that this
> > event
> > implies more information than the idea on the presenter thats it's being
> > edited by the user, it also be another object. So I'm thinking about
> > onKeyPressed or onKeyReleased event but I don't have idea on how to know
> > when aKeyEvent is a number (from keyboard or numpad).
>
> Browse for #aspectTriggers:. There is an example in PersonalAccountShell.
> Assuming you are using the built-in text controls, you can set the
> #updatePerChar aspect to true?
>
> --
> Regards
> Hwee Boon
> MotionObj


Reply | Threaded
Open this post in threaded view
|

Re: Presenters values depending on each other

Yar Hwee Boon-3
On Thu, 2 Sep 2004 10:28:14 -0300, Sebastián Sastre  
<[hidden email]> wrote:

>    It could be an example of the situation I have, if you can edit  
> Balance
> and initial balance simultaneuosly (one changing by the users entry, and  
> the
> other by the model, and viceversa). So it's not exactly the problem I'm
> bringing.

Sorry if I misunderstood. Can you give a simplified example?

--
Regards
Hwee Boon
MotionObj


Reply | Threaded
Open this post in threaded view
|

Re: Presenters values depending on each other

Sebastián Sastre
Dear Hwee,

I can give you some code (that does not work but you'll undestand it's
intention):

ItemPropertiesDialog>>createSchematicWiring
"Create the presenters contained by the receiver"

super createSchematicWiring.

(self presenterNamed:'retailPrice') when:#valueChanged:
send:#onRetailPriceChanged: to:self.

(self presenterNamed:'repositionCost') when:#valueChanged:
send:#onRepositionCostChanged: to:self.



ItemPropertiesDialog>>onRepositionCostChanged:aKeyEvent

(self presenterNamed:'retailPrice') value: (self model repositionCost /
((100 - self model offerDiscount) /100)) asFloat.


ItemPropertiesDialog>>onRetailPriceChanged: aKeyEvent

(self presenterNamed:'repositionCost') value: (self model retailPrice -
(self model retailPrice * self consultor weeklyDiscount / 100)) asFloat.


The problem is that #valueChanged could be from a keyboard event or other
object intervention, and in this situation (this properties dialog) you need
to edit the cost and see retail to change, or, edit the retail, and see the
cost to change.

    Do I make myself to be understood?

    best regards,

--
Sebastián Sastre
[hidden email]
www.seaswork.com.ar



"Yar Hwee Boon" <[hidden email]> escribió en el mensaje
news:[hidden email]...

> On Thu, 2 Sep 2004 10:28:14 -0300, Sebastián Sastre
> <[hidden email]> wrote:
>
> >    It could be an example of the situation I have, if you can edit
> > Balance
> > and initial balance simultaneuosly (one changing by the users entry, and
> > the
> > other by the model, and viceversa). So it's not exactly the problem I'm
> > bringing.
>
> Sorry if I misunderstood. Can you give a simplified example?
>
> --
> Regards
> Hwee Boon
> MotionObj


Reply | Threaded
Open this post in threaded view
|

Re: Presenters values depending on each other

Christopher J. Demers
"Sebastián Sastre" <[hidden email]> wrote in message
news:[hidden email]...
> The problem is that #valueChanged could be from a keyboard event or other
> object intervention, and in this situation (this properties dialog) you
need
> to edit the cost and see retail to change, or, edit the retail, and see
the
> cost to change.
...

Perhaps Object<<noEventsDo: may be helpful here.  If you do not want
programmatic value changes to a presenter to trigger a valueChanged event
than you can wrap the set in a noEventsDo: block. ie:

presenterA noEventsDo: [presenterA value: presenterB value * 2].

Chris


Reply | Threaded
Open this post in threaded view
|

Re: Presenters values depending on each other

Yar Hwee Boon-3
In reply to this post by Sebastián Sastre
On Thu, 2 Sep 2004 18:11:04 -0300, Sebastián Sastre  
<[hidden email]> wrote:

> The problem is that #valueChanged could be from a keyboard event or other
> object intervention, and in this situation (this properties dialog) you  
> need
> to edit the cost and see retail to change, or, edit the retail, and see  
> the
> cost to change.
>
>     Do I make myself to be understood?

The object can be changed from outside the dialog also? In this case, I  
*assume* that it is a shell instead since a dialog is most probably  
buffered. Install http://motionobj.com/Linear.pac and run this in the  
workspace.

=======
model := LinearModel new.
LinearEquationShell showOn: model    "try modifying the values the text  
fields"
model first: 10.   "simulate changes from outside the shell"
=======

Is this what you are describing?

--
Regards
Hwee Boon
MotionObj


Reply | Threaded
Open this post in threaded view
|

Re: Presenters values depending on each other

Sebastián Sastre
In reply to this post by Christopher J. Demers
> presenterA noEventsDo: [presenterA value: presenterB value * 2].
>
> Chris

Chris,

    it worked almost exacly like that.

    thank you very very very much !

Seb