xsharp.eu • DateTimePicker change available in EditFocusChange? - Page 2
Page 2 of 2

DateTimePicker change available in EditFocusChange?

Posted: Tue Oct 25, 2022 3:23 am
by jonhn
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

DateTimePicker change available in EditFocusChange?

Posted: Tue Oct 25, 2022 7:01 am
by jonhn
Thanks Jamal,
Can this also be use in X# for VO dialect?

DateTimePicker change available in EditFocusChange?

Posted: Tue Oct 25, 2022 7:47 am
by Chris
Hi John,
jonhn post=24256 userid=4531 wrote:Thanks Jamal,
Can this also be use in X# for VO dialect?
Yes, the same should work in X# as well, you will just need to update the (same named) files in your XIDE folder.
If it's not working as intended, please let us know!

DateTimePicker change available in EditFocusChange?

Posted: Tue Oct 25, 2022 8:33 am
by Karl-Heinz
Hi Jonathan,

you may not add my posted "Class control" snippets to your app! I only posted this code, which is part of the VO Gui source code, to describe the message flow. All you need is your already created method:

Code: Select all

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


btw. ? or ?? sends the output to a console window. To make it work:

- If you use VO add the "TerminalLight" Lib.
- if you use X# change the Target from "Windows" to "Console"

regards
Karl-Heinz

DateTimePicker change available in EditFocusChange?

Posted: Tue Oct 25, 2022 9:03 am
by jonhn
Ahhhh, yes... thank you.
Now that you explained it slowly enough (and in a large font) for me, I've finally got it, and indeed it seems to be working at my end.
Thank you for the suggestion and clarification!