Fwd: problem with updating checkBoxes in morph

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

Fwd: problem with updating checkBoxes in morph

Stéphane Ducasse


Begin forwarded message:

From: "Gary Chambers" <[hidden email]>
Date: October 7, 2009 12:40:16 PM GMT+02:00
To: Stéphane Ducasse <[hidden email]>
Subject: RE: [Pharo-project] problem with updating checkBoxes in morph

The button inherits from three-phase button and, for "compatability" also does not call the Morph method for mouseDown (except when disabled). That is why the event is never triggered.
 
Most morphs of the pluggable variety expect to work with proper model objects, not always easy with a (potentially dynamic) collection.
Perhaps an intermediate model would be appropriate for each checkbox that holds the selection state and end-model (some kind of "context" it seems from his original post). On state change an event could be triggered (preferred over change/update).
 
Perhaps he should be using radio buttons, given the implication of "one-of-many" (is the same class, just different appearance).
 
 -----Original Message-----
From: Stéphane Ducasse [mailto:[hidden email]]
Sent: 07 October 2009 11:23 AM
To: Gary Chambers
Subject: Fwd: [Pharo-project] problem with updating checkBoxes in morph

did you notice this strange behavior with checkboxes?
In this example, when you click on the check box, all the other checkboxes should be updated and selected.
This works when you click on the checkbox label BUT NOT on the checkbox button.

stef
Begin forwarded message:

From: Cyrille Delaunay <[hidden email]>
Date: October 7, 2009 10:10:07 AM GMT+02:00
Subject: Re: [Pharo-project] problem with updating checkBoxes in morph
Reply-To: [hidden email]

=>  this is a small exemple of my problem that you can run in your own image (also available in the class side of UITheme by merging the 'Polymorph-Widgets' package in the PharoInBox repository) :

exampleProblemUpdatingCheckboxes
"little example to show the problem with the method #on:send:to:with for a CheckboxMorph :
In this example, when you click on the check box, all the other checkboxes should be updated and selected.
This works when you click on the checkbox label BUT NOT on the checkbox button.
"
"self exampleProblemUpdatingCheckboxes"
| builder dialog checkboxes |
checkboxes := OrderedCollection new.
builder := ExampleBuilderMorph new.
dialog := (builder newPluggableDialogWindow: 'Example :') useDefaultOKButton .

dialog contentMorph: (
dialog newGroupboxForAll: {
checkboxes add: 
(dialog newCheckboxFor: 
(ValueHolder new contents: false)
getSelected: #contents 
setSelected: #contents: 
label: '1' 
help: '').
checkboxes add: 
(dialog newCheckboxFor: 
(ValueHolder new contents: false)
getSelected: #contents 
setSelected: #contents: 
label: '2' 
help: '').
checkboxes add:
(dialog newCheckboxFor: 
(ValueHolder new contents: false)
getSelected: #contents 
setSelected: #contents: 
label: '3' 
help: '').
}
); model: nil.
checkboxes do: [:each | each on: #click send: #updateCheckboxes:a:b: to: self withValue: checkboxes ].
builder openModal: dialog.

=> and the method :

updateCheckboxes: collectionOfCheckboxes a:a b:b

collectionOfCheckboxes do: [:each | each buttonMorph  selected: true].


2009/10/6 Igor Stasenko <[hidden email]>
I'm a bit wonder, why you sending a #buttonMorph to checkbox morph,
trying to intercept
a messages?
As to me this is a wrong approach, because you as a user of checkbox,
should not care
about its internals, and speak directly with checkbox public layer ,
but not with its internal components.

2009/10/6 Cyrille Delaunay <[hidden email]>:
> here is the code of the method creating the checkboxes:

> checkBoxes := OrderedCollection new.
> builder := ExampleBuilderMorph new.
> dialog := (builder newPluggableDialogWindow: 'Context to import :')
> useDefaultOKButton .
> dialog contentMorph: (
> dialog newRow: {
> dialog newGroupboxForAll:
> (self allContexts  collect: [:each | (checkBoxes add: (dialog
> newCheckboxFor:
> (ValueHolder new
> contents: (collectionWithItemsToCheck includes: each))
> getSelected: #contents
> setSelected: #contents:
> label: each asString
> help: '')
> ).
> ])
> }
> );
> model: nil.
> checkBoxes do: [:each | each on: #click send: #updateDependenciesFor:i:a:
> to: self withValue: each label asString].
> => That code make what I want when I click on the label, but with:
> checkBoxes do: [:each | each buttonMorph on: #click send:
> #updateDependenciesFor:i:a: to: self withValue: each label asString].
> => nothing happen when I click on the checkbox button.
>
> 2009/10/6 Stéphane Ducasse <[hidden email]>
>>
>> can you send some text :)
>>
>> On Oct 6, 2009, at 2:02 PM, Cyrille Delaunay wrote:
>>
>> > I join a screenshot of my code.
>> >
>> > 2009/10/6 Stéphane Ducasse <[hidden email]>
>> > cyrille
>> >
>> > do you have a piece of code to illustrate your problem?
>> > Let me rephrase our discussions:
>> >
>> >        you can get the associated checkbox event (set by
>> >        on: #click send: #amessage to: receiver) raised only
>> >        when you click on the label but not on the tick.
>> >
>> > And that
>> >        checkbox buttonMorph on: #click send: #amessage to: receiver,
>> >        is not working on click
>> > but   checkbox buttonMorph on: #mouseDown send: #amessage to:
>> > receiver,
>> >        is.
>> >
>> >
>> > Stef
>> >
>> >
>> >
>> > On Oct 6, 2009, at 12:08 PM, Cyrille Delaunay wrote:
>> >
>> > > Hi,
>> > >
>> > > Here is what I want to do:
>> > >
>> > > - I have checkbox: ChekboxMorph new
>> > > - A checkbox is made of a label and a button
>> > > - I want to do a specific action when there is a mouse click on the
>> > > button
>> > >
>> > > For that:
>> > >
>> > > - I saw that there is a method #on:send:to: in Morph with wich we
>> > > can do:
>> > >
>> > > checkbox on: #click send: #amessage to: receiver
>> > >
>> > > Problem:
>> > >
>> > > - when I do
>> > >          checkbox on: #click send: #amessage to: receiver,
>> > >   all is ok.
>> > > - when I do
>> > >          checkbox buttonMorph on: #click send: #amessage to:
>> > receiver,
>> > >   to consider the click on the button, it doesn't work, the event is
>> > > never handled (whereas #mouseDown for example is handled).
>> > >
>> > >
>> > > _______________________________________________
>> > > Pharo-project mailing list
>> > > [hidden email]
>> > > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>> >
>> >
>> > _______________________________________________
>> > Pharo-project mailing list
>> > [hidden email]
>> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>> >
>> > <checkboxes.tiff>_______________________________________________
>> > Pharo-project mailing list
>> > [hidden email]
>> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>
>>
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>



--
Best regards,
Igor Stasenko AKA sig.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project



Click here to report this email as spam.



 

ü Consider your responsibility to the environment - think before you print!

*******************************************************************************************************************************************

This email is from Pinesoft Limited. Its contents are confidential to the intended recipient(s) at the email address(es) to which it has been addressed. It may not be disclosed to or used by anyone other than the addressee(s), nor may it be copied in anyway. If received in error, please contact the sender, then delete it from your system. Although this email and attachments are believed to be free of virus, or any other defect which might affect any computer or IT system into which they are received and opened, it is the responsibility of the recipient to ensure that they are virus free and no responsibility is accepted by Pinesoft for any loss or damage arising in any way from receipt or use thereof.

******************************************************************************************************************************************* 

Pinesoft Limited are registered in England, Registered number: 2914825. Registered office: 266-268 High Street, Waltham Cross, Herts, EN8 7EA
 


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project