How to connect to AbtCwDateTimePickerView event when it drops

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

How to connect to AbtCwDateTimePickerView event when it drops

Louis LaBrunda
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

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/d3bd48e3-e340-4b09-8ff4-03a4f2683acan%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: How to connect to AbtCwDateTimePickerView event when it drops

Marcus Wagner
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.

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/a811f831-b06d-4629-b21f-23a1c0a218f3n%40googlegroups.com.

datepickerapp.zip (21K) Download Attachment