DateTimePicker change available in EditFocusChange?
Posted: Tue Oct 25, 2022 3:23 am
Thanks Karl,
I made a small app to try your suggestion, but am not sure about a couple of things. I've copied your code almost literally, and it compiles and runs, but... I don't think it is ever calling the dispatch in my case.
1) oParent - where should this value come from? I have tried declaring it in the method below and taking _GetInst(), but I don't think it is right.
2) Where do I look for the results of these? - with the "?" ? oControlFocusChangeEvent:Control:Namesym , oControlFocusChangeEvent:GotFocus
Are these visible in the debugger?
Here's what I did...
METHOD Dispatch(oEvent) CLASS Control
LOCAL uRet AS USUAL
//PP-040421 Improved focus handling
IF oEvent:msg == WM_SETFOCUS .OR. oEvent:msg == WM_KILLFOCUS
//uRet := SELF:FocusChange(__ObjectCastClassPtr(oEvt, __pCFocusChangeEvent))
uRet := SELF:FocusChange(FocusChangeEvent{oEvent})
ENDIF
RETURN SUPER:Dispatch(oEvent)
METHOD FocusChange(oFocusChangeEvent) CLASS Control
//PP-040518 Update from S Ebert
LOCAL oParent AS OBJECT
oParent := _GetInst()
IF IsInstanceOf(oParent,#DataWindow) .OR. IsInstanceOf(oParent,#DialogWindow)
//RETURN oParent:ControlFocusChange(__ObjectCastClassPtr(oFocusChangeEvent, __pCControlFocusChangeEvent))
RETURN oParent:ControlFocusChange(ControlFocusChangeEvent{oFocusChangeEvent})
ELSEIF IsInstanceOf(oParent, #__FormWindow) //It's a browser of a DataWindow
IF oFocusChangeEvent:GotFocus
oParent:DataWindow:LastFocus := SELF
ENDIF
ENDIF
RETURN NIL
METHOD ControlFocusChange(oControlFocusChangeEvent) CLASS DATAWINDOW1
SUPER:ControlFocusChange(oControlFocusChangeEvent)
? oControlFocusChangeEvent:Control:Namesym , oControlFocusChangeEvent:GotFocus
IF IsInstanceOf ( oControlFocusChangeEvent:Control , #DATETIMEPICKER ) .and. oControlFocusChangeEvent:Control:NameSym == #DATETIMEPICKER2 .and. oControlFocusChangeEvent:GotFocus
?? "", oControlFocusChangeEvent:Control:SelectedDate
ENDIF
RETURN NIL
I made a small app to try your suggestion, but am not sure about a couple of things. I've copied your code almost literally, and it compiles and runs, but... I don't think it is ever calling the dispatch in my case.
1) oParent - where should this value come from? I have tried declaring it in the method below and taking _GetInst(), but I don't think it is right.
2) Where do I look for the results of these? - with the "?" ? oControlFocusChangeEvent:Control:Namesym , oControlFocusChangeEvent:GotFocus
Are these visible in the debugger?
Here's what I did...
METHOD Dispatch(oEvent) CLASS Control
LOCAL uRet AS USUAL
//PP-040421 Improved focus handling
IF oEvent:msg == WM_SETFOCUS .OR. oEvent:msg == WM_KILLFOCUS
//uRet := SELF:FocusChange(__ObjectCastClassPtr(oEvt, __pCFocusChangeEvent))
uRet := SELF:FocusChange(FocusChangeEvent{oEvent})
ENDIF
RETURN SUPER:Dispatch(oEvent)
METHOD FocusChange(oFocusChangeEvent) CLASS Control
//PP-040518 Update from S Ebert
LOCAL oParent AS OBJECT
oParent := _GetInst()
IF IsInstanceOf(oParent,#DataWindow) .OR. IsInstanceOf(oParent,#DialogWindow)
//RETURN oParent:ControlFocusChange(__ObjectCastClassPtr(oFocusChangeEvent, __pCControlFocusChangeEvent))
RETURN oParent:ControlFocusChange(ControlFocusChangeEvent{oFocusChangeEvent})
ELSEIF IsInstanceOf(oParent, #__FormWindow) //It's a browser of a DataWindow
IF oFocusChangeEvent:GotFocus
oParent:DataWindow:LastFocus := SELF
ENDIF
ENDIF
RETURN NIL
METHOD ControlFocusChange(oControlFocusChangeEvent) CLASS DATAWINDOW1
SUPER:ControlFocusChange(oControlFocusChangeEvent)
? oControlFocusChangeEvent:Control:Namesym , oControlFocusChangeEvent:GotFocus
IF IsInstanceOf ( oControlFocusChangeEvent:Control , #DATETIMEPICKER ) .and. oControlFocusChangeEvent:Control:NameSym == #DATETIMEPICKER2 .and. oControlFocusChangeEvent:GotFocus
?? "", oControlFocusChangeEvent:Control:SelectedDate
ENDIF
RETURN NIL