How to connect to AbtCwDateTimePickerView event when it drops

36 views
Skip to first unread message

Louis LaBrunda

unread,
Nov 25, 2020, 5:44:05 PM11/25/20
to VA Smalltalk
Hi Everyone,

Happy Thanksgiving if that is something you celebrate.

I'm using a Date Picker (AbtCwDateTimePickerView) and would like to catch an event when (and do something) it drops down.  I think it signals (#signalEvent:) #dropdownChanged when it drops down.  Normally I could make a connection from the Date Picker part to a method but #dropdownChanged isn't available and #dropdown doesn't seem to work.

This smells like a design problem of AbtCwDateTimePickerView.

Any ideas how to do this or get around the problem?

I'm tried to set various signal catchers but nothing works.  Thanks in advance.

Lou

Marcus Wagner

unread,
Dec 8, 2020, 9:48:37 AM12/8/20
to VA Smalltalk
Hi Lou,
the underlying windows widget class SysDateTimePick32 has a special design - it creates a combobox on the fly to achieve its functions.
This design has many implications and produced a long list of contributions (stackoverflow e.g.) how to achieve certain effects, which are thought to be straight forward but are not.
The Smalltalk class OSDateTimePicker thus covers only the official interface of the windows control, which is not exposing the internal combobox at all.
Here the (proven) way to achieve your effect. The result has not been tested in complex scenarios e.g. in combination with drag & drop, etc.
Attached find a repository containing the example WamAbtCwDateTimePickerViewApp (import the application and load it to test)

MarcusPicker.JPG

Description
1. OsDateTimePicker has to hook the windows button down event and to implement wmLbuttondown: wParam with: lParam, to fire the required OSxSelect event. Extend the class OsDateTimePicker with this instance method
----
wmLbuttondown: wParam with: lParam  
----
2. The standard CwDateTimePicker class (covering OsDateTimePicker) does not support a callback and provides no instance variable for this. A solution is to create a subclass CwDateTimePickerEx holding an instance variable xmNactivateCallback and five methods to support the callback
----
CwDateTimePicker subclass: #CwDateTimePickerEx
    classInstanceVariableNames: ''
    instanceVariableNames: 'xmNactivateCallback '
    classVariableNames: ''
    poolDictionaries: ''
----
activateCallback
----
activateCallback: resourceValue
----
callActivateCallback: anEvent
----
callbackData   
----
updateActivateCallback
"this hooks the OS event to the CW widget's callback"
----
3. The visual part AbtCwDateTimePickerView (using CwDateTimePicker) has to be enhanced by (a new subclass) AbtCwDateTimePickerViewEx (to make use of the enhanced CwDateTimePickerEx):

AbtCwDateTimePickerView subclass: #AbtCwDateTimePickerViewEx
    classInstanceVariableNames: ''
    instanceVariableNames: 'clickedHandlers '
    classVariableNames: ''
    poolDictionaries: ''

AbtCwDateTimePickerViewEx in turn makes use of CwDateTimePickerEx and its callback and maps it to visual parts.
It has to expose a click action and a clicked event. This requires seven instance methods and one class method (not to mention the usual generated methods _PRAGMA_IS, IS_..., abtPrimFlushInterfaceSpecCache and the like).
----
click
----
clicked
----
clicked: aHandlerCollection
----
postCreationInitialization
----
release
----
removeInterestSelect: aBlock
----
userClicked: aWidget clientData: clientData callData: callData
---
This class method will make use the modified common widget and its callback
---
cwWidgetClass
----
4. The visual part AbtCwDateTimePickerViewEx has to expose the event clicked and the action click. And for convenience, the part can be integrated in the composition editor (so that the enhanced picker can be used when composing new visual parts). This is left out here.

Usage of AbtCwDateTimePickerViewEx : when it is dropped in a composition of visual window part, you can now connect click (as action) or clicked (as event) as usual, e.g. to connect it to a script. I connected the clicked event to this script of a view
WamTestPickerView>>clicked
    CwAppContext default asyncExecInUI: [ Transcript cr; show: 'XXX'].
Whenever clicking on the pickers combobox yields "XXX" on the Transcript, as expected.

datepickerapp.zip
Reply all
Reply to author
Forward
0 new messages