Hi guys We found a bug programming lightsout. Apparently when we click and do not move the mouse, one click event is received. Now if we click and move the mouse, it looks like two clicks are received. You can see that really easily on the Class side toggle in Nautilus or in the slice selector, since both use the SwitchMorph. I'm going to bed now but I think that we should have a look at it and smash it :) Stef
Hi It seems that the bug is link with the fact that the cursor get outside the bounds or not. If you click and do not move or move but stay inside the morph it is ok Now if you click and the mouse gets outside the bounds we get the funny and bad behavior. I'm definitely exhausted now to thinkâ¦. but here is the code for the night hackers :) mouseDown: evt oldColor := self fillStyle. mouseMove: evt (self containsPoint: evt cursorPoint) ifTrue: [self setSwitchState: (oldColor = offColor)] ifFalse: [self setSwitchState: (oldColor = onColor)]. mouseUp: evt (self containsPoint: evt cursorPoint) ifTrue: [ "toggle and do action" self setSwitchState: (oldColor = offColor). self doButtonAction] ifFalse: [ "restore old appearance" self setSwitchState: (oldColor = onColor)].
may be the behavior is normal because it wants to encode that - if we press and keep pressed and get outside the morph then nothing should happen once we release the button. Now there is still something strange. It is really slow and this behavior should be customised because for certain cases I just want to get the click in any situation. Stef (good night now for real). On May 20, 2013, at 10:50 PM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
Hi
It seems that the bug is link with the fact that the cursor get outside the bounds or not. If you click and do not move or move but stay inside the morph it is ok Now if you click and the mouse gets outside the bounds we get the funny and bad behavior.
I'm definitely exhausted now to thinkâ¦. but here is the code for the night hackers :)
mouseDown: evt
oldColor := self fillStyle.
mouseMove: evt
(self containsPoint: evt cursorPoint) ifTrue: [self setSwitchState: (oldColor = offColor)] ifFalse: [self setSwitchState: (oldColor = onColor)].
mouseUp: evt
(self containsPoint: evt cursorPoint) ifTrue: [ "toggle and do action" self setSwitchState: (oldColor = offColor). self doButtonAction] ifFalse: [ "restore old appearance" self setSwitchState: (oldColor = onColor)].
I will try to have a look tomorrow afternoon :) Ben On May 20, 2013, at 10:50 PM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
Hi
It seems that the bug is link with the fact that the cursor get outside the bounds or not. If you click and do not move or move but stay inside the morph it is ok Now if you click and the mouse gets outside the bounds we get the funny and bad behavior.
I'm definitely exhausted now to thinkâ¦. but here is the code for the night hackers :)
mouseDown: evt
oldColor := self fillStyle.
mouseMove: evt
(self containsPoint: evt cursorPoint) ifTrue: [self setSwitchState: (oldColor = offColor)] ifFalse: [self setSwitchState: (oldColor = onColor)].
mouseUp: evt
(self containsPoint: evt cursorPoint) ifTrue: [ "toggle and do action" self setSwitchState: (oldColor = offColor). self doButtonAction] ifFalse: [ "restore old appearance" self setSwitchState: (oldColor = onColor)].
Ben I started to understand what is wrong: - if I click on the moprh + keep down and slightly move -> the morph toggles as if I would have released the mouse button. and this is not linked to the fact that I get outside the bounds of the morph. Stef On May 20, 2013, at 10:55 PM, Benjamin <benjamin.vanryseghem.pharo@gmail.com> wrote:
I will try to have a look tomorrow afternoon :)
Ben
On May 20, 2013, at 10:50 PM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
Hi
It seems that the bug is link with the fact that the cursor get outside the bounds or not. If you click and do not move or move but stay inside the morph it is ok Now if you click and the mouse gets outside the bounds we get the funny and bad behavior.
I'm definitely exhausted now to thinkâ¦. but here is the code for the night hackers :)
mouseDown: evt
oldColor := self fillStyle.
mouseMove: evt
(self containsPoint: evt cursorPoint) ifTrue: [self setSwitchState: (oldColor = offColor)] ifFalse: [self setSwitchState: (oldColor = onColor)].
mouseUp: evt
(self containsPoint: evt cursorPoint) ifTrue: [ "toggle and do action" self setSwitchState: (oldColor = offColor). self doButtonAction] ifFalse: [ "restore old appearance" self setSwitchState: (oldColor = onColor)].
I will try to clean a bit But this "SimpleButtonMorph" is not so simple Now by redefining SimpleSwitchMorph>>mouseMove: evt ^ self I addressed the bug. But all the code tells me that this is too complex. Ben I would like to pair program with you to define a B Here is a list of things I saw and found not good. mouseDownMilleseconds is not usedâ¦. IconicButton>>interactSelector ^ #interact IconicButton>>update: aSelector aSelector = self interactSelector ifTrue: [ ^ self doButtonAction ]. super update: aSelector SimpleButtonMorph>>label | s | s := ''. self allMorphsDo: [:m | (m isKindOf: StringMorph) ifTrue: [s := m contents]]. ^ s and SimpleButtonMorph>>label: aString font: aFont label ifNotNil: [label delete]. label := StringMorph contents: aString font: (aFont ifNil: [StandardFonts buttonFont]). self extent: (label width + 6) @ (label height + 6). label position: self center - (label extent // 2). self addMorph: label. label lock SimpleButtonMorph>>actionSelector: aSymbolOrString (nil = aSymbolOrString or: ['nil' = aSymbolOrString or: [aSymbolOrString isEmpty]]) ifTrue: [^ actionSelector := nil]. actionSelector := aSymbolOrString asSymbol. berk! SimpleButtonMorph>>arguments: aCollection arguments := aCollection asArray copy. we copy here and there. SimpleSwitchMorph>>doButtonAction "Perform the action of this button. The last argument of the message sent to the target is the new state of this switch." | newState | (target notNil and: [actionSelector notNil]) ifTrue: [newState := color = onColor. target perform: actionSelector withArguments: (arguments copyWith: newState)]
participants (3)
-
Benjamin -
stephane ducasse -
Stéphane Ducasse