How to receive #leftButtonDoubleClicked: events bypassing the #singleClicked ones ?

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

How to receive #leftButtonDoubleClicked: events bypassing the #singleClicked ones ?

FU Berlin-2
I wrote a new ListPresenter with a ListView view where the clicks are
handled as in MultipleSelectionListBoxes, i.e. the selections are
toggled.
But when I want to trigger a #doubleClick: event I always have to
reset the previous selection state.
Has anyone experience on this matter ?
Is this a Dolphin or a Windows problem ?

I know it is tricky. I tried a few things but, you guys, know
certainly better.

Jon


Reply | Threaded
Open this post in threaded view
|

Re: How to receive #leftButtonDoubleClicked: events bypassing the #singleClicked ones ?

Ian Bartholomew-18
Jon,

> Is this a Dolphin or a Windows problem ?

I don't really think it's a problem - it's just the way it works.

For a double-click Windows (according to the docs and verified through a
little experimentation) sends 4 messages

WM_*BUTTONDOWN
WM_*BUTTONUP
WM_*BUTTONDBLCLICK
WM_*BUTTONUP

Dolphin responds to the first pair by generating a single click event
and to the second pair by generating a double click event.

I can't see any way of preventing this behaviour so it looks like you
have two choices.

1) A double click assumes a single click has just occurred and reverses
the current selection state (the way you currently work?)
2) Delay the single click until you know the double click is not
going to happen.

I've got a version of (2) to work but it's not particularly user
friendly. The delay between clicking the mouse button and the selection
changing is a bit off-putting.

Save the following class and methods into a file, file it into the image
and then evaluate ...

test := Test show.
test list: #('111' '222' '333' '444' '555' '666')

Single clicking an item toggles it (after a short delay) but double
clicking doesn't.

I definitely prefer the normal MultipleSelection scheme where you have
to use the Control key to indicate deselection of an item.

-~-~-~ cut here
ListView subclass: #Test
instanceVariableNames: 'flag'
classVariableNames: ''
poolDictionaries: ''
classInstanceVariableNames: ''!

Test guid: (GUID fromString: '{A2996D13-777D-498E-8572-E9658E95D697}')!
Test comment: ''!
!Test categoriesForClass!MVP-Views! !

!Test methodsFor!
onLeftButtonPressed: aMouseEvent
flag := aMouseEvent.
[Processor sleep: 200.
self checkToggle] fork.
^0! !
!Test categoriesFor: #onLeftButtonPressed:!public! !

!Test methodsFor!
onLeftButtonDoubleClicked: aMouseEvent
flag := nil.
^super onLeftButtonDoubleClicked: aMouseEvent! !
!Test categoriesFor: #onLeftButtonDoubleClicked:!public! !

!Test methodsFor!
checkToggle
flag ifNotNil:
[:mouseEvent |
self hasSelection
ifTrue: [self selectionOrNil: nil]
ifFalse:
[(self itemFromPoint: mouseEvent position) ifNotNil: [:item | self
selectionByIndex: item]]]! !
!Test categoriesFor: #checkToggle!public! !

-~-~-~ cut here

--
Ian


Reply | Threaded
Open this post in threaded view
|

Re: How to receive #leftButtonDoubleClicked: events bypassing the #singleClicked ones ?

FU Berlin-2
Ian,
Thank you for your help. I'll use it. If it is too uncomfortable I can
easily remove it because it is just simple.
Before, I also preferred the MultipleSelectionListBox because it is
the only kind of lists where you can select "none".
But, you have no columns there, you cannot drag elements and you
cannot change the foreground colors as I don't like the Windows blue.
I prefer warm earth-like colors. I like very much the light yellow one
in all Dolphin document presenters.

Jon


Reply | Threaded
Open this post in threaded view
|

Re: How to receive #leftButtonDoubleClicked: events bypassing the #singleClicked ones ?

Ian Bartholomew-18
Jon,

Just checking.

> Before, I also preferred the MultipleSelectionListBox because it is
> the only kind of lists where you can select "none".
> But, you have no columns there, you cannot drag elements and you
> cannot change the foreground colors as I don't like the Windows blue.

There are two pairs of views that can be used with ListPresenters /
MultipleSelectionListPresenters -

ListBox / MultipleSelectionListBox implement the original (simple)
Windows ListBox control.

ListView / MultipleSelectionListView implement the newer Windows
CommonControl ListView which does have columns, dragging and the ability
to change fore/back colours.

I was just wondering if you were trying to use the "Box" version when
you really wanted the "View" version?

--
Ian