=> 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 <[email protected]>
> 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 <[email protected]>:
> > 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 <[email protected]>
> >>
> >> 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 <[email protected]>
> >> > 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
> >> > > [email protected]
> >> > > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
> >> >
> >> >
> >> > _______________________________________________
> >> > Pharo-project mailing list
> >> > [email protected]
> >> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
> >> >
> >> > <checkboxes.tiff>_______________________________________________
> >> > Pharo-project mailing list
> >> > [email protected]
> >> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
> >>
> >>
> >> _______________________________________________
> >> Pharo-project mailing list
> >> [email protected]
> >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
> >
> >
> > _______________________________________________
> > Pharo-project mailing list
> > [email protected]
> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
> >
>
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>
> _______________________________________________
> Pharo-project mailing list
> [email protected]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project