Which Form Field Has Focus? SOLVED
Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan
Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
-
- User
- Posts: 9
- Joined: Wed Mar 29, 2017 1:36 am
Which Form Field Has Focus?
Question #1: How can I get a handle to the IPXC_FormField that currently has focus?
----------------------------------------------------------------
Also, I am using IUIX_EventMonitor to capture keystrokes with EnableEventListening set to 'e.beforeShowContextMenu'.
The event handler is:
Function TUIEventMon.OnEventMonitor(Const Obj : IUIX_Obj ; Const pEvent : IUIX_Event) : HResult ; stdcall ;
This event handler provides Obj : IUIX_Obj which oddly contains a reference to the calling/focused field in the third child; Obj.Children[2].
Question #2: Why is it in the third child?
I can use this to get the current field text (Obj.Children[2].Text), but I can not get the field name or other IPXC_FormField information. So...
Question #3: How can I use Obj : IUIX_Obj to get a handle to the form field that evoked the call to OnEventMonitor?
Thanks.
- John
----------------------------------------------------------------
Also, I am using IUIX_EventMonitor to capture keystrokes with EnableEventListening set to 'e.beforeShowContextMenu'.
The event handler is:
Function TUIEventMon.OnEventMonitor(Const Obj : IUIX_Obj ; Const pEvent : IUIX_Event) : HResult ; stdcall ;
This event handler provides Obj : IUIX_Obj which oddly contains a reference to the calling/focused field in the third child; Obj.Children[2].
Question #2: Why is it in the third child?
I can use this to get the current field text (Obj.Children[2].Text), but I can not get the field name or other IPXC_FormField information. So...
Question #3: How can I use Obj : IUIX_Obj to get a handle to the form field that evoked the call to OnEventMonitor?
Thanks.
- John
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Which Form Field Has Focus?
Hello John,
Well that's not the right way of doing this. The correct way would be to listen to the https://sdkhelp.pdf-xchange.com/vi ... or_started event and get the IPXV_TextEditor interface from it. There you can see whether the IPXC_Annotation (that you can get with the Annot property) is a widget annotation and has a https://sdkhelp.pdf-xchange.com/vi ... tion_Field property.
Also, the https://sdkhelp.pdf-xchange.com/vi ... extChanged event would give you the current text from the current text editor.
Note that these events will be called if any text box/edit/combo box/text annotation etc. will be edited - so basically you will have to check whether it's a for field as I told you.
Cheers,
Alex
Well that's not the right way of doing this. The correct way would be to listen to the https://sdkhelp.pdf-xchange.com/vi ... or_started event and get the IPXV_TextEditor interface from it. There you can see whether the IPXC_Annotation (that you can get with the Annot property) is a widget annotation and has a https://sdkhelp.pdf-xchange.com/vi ... tion_Field property.
Also, the https://sdkhelp.pdf-xchange.com/vi ... extChanged event would give you the current text from the current text editor.
Note that these events will be called if any text box/edit/combo box/text annotation etc. will be edited - so basically you will have to check whether it's a for field as I told you.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 9
- Joined: Wed Mar 29, 2017 1:36 am
Re: Which Form Field Has Focus?
Hi Alex,
Thanks for the reply.
Yes, I need to use the active IPXV_TextEditor as follows:
IPXV_TextEditor.Get_Annot ---> Annot.Get_Field
to get the active IPXC_FormField. That's the part I was missing.
However, I think it is easier to get the active IPXV_TextEditor by using IPXV_Document.ActiveTextEditor. This seems to work well.
Am I missing something?
Thanks.
- John
Thanks for the reply.
Yes, I need to use the active IPXV_TextEditor as follows:
IPXV_TextEditor.Get_Annot ---> Annot.Get_Field
to get the active IPXC_FormField. That's the part I was missing.
However, I think it is easier to get the active IPXV_TextEditor by using IPXV_Document.ActiveTextEditor. This seems to work well.
Am I missing something?
Thanks.
- John
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Which Form Field Has Focus? SOLVED
Hello John,
If you are using those events that I previously mentioned then you should get the interface from the parameter - that would assure that you are in the correct document in the correct frame.
Cheers,
Alex
If you are using those events that I previously mentioned then you should get the interface from the parameter - that would assure that you are in the correct document in the correct frame.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 9
- Joined: Wed Mar 29, 2017 1:36 am
Re: Which Form Field Has Focus?
Actually, here is a much easier/better way to read and write to the active form field (in Delphi code):
Var
PDFEditorXC :TPXV_Control ;
LDoc : IPXV_Document ;
LTextEditor : IPXV_TextEditor ;
LEdit : IUIX_Edit ;
//...
Begin
// create PDFEditorXC
LDoc := PDFEditorXC.Doc ;
LTextEditor := LDoc.ActiveTextEditor ;
If Assigned(LTextEditor) then
Begin
If LTextEditor.Get_EditCtl(LEdit) = S_OK then
If Assigned(LEdit) then
LEdit.Text := 'XXX Hello XXX' ;
End ;
End ;
Var
PDFEditorXC :TPXV_Control ;
LDoc : IPXV_Document ;
LTextEditor : IPXV_TextEditor ;
LEdit : IUIX_Edit ;
//...
Begin
// create PDFEditorXC
LDoc := PDFEditorXC.Doc ;
LTextEditor := LDoc.ActiveTextEditor ;
If Assigned(LTextEditor) then
Begin
If LTextEditor.Get_EditCtl(LEdit) = S_OK then
If Assigned(LEdit) then
LEdit.Text := 'XXX Hello XXX' ;
End ;
End ;
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Which Form Field Has Focus?
Hello JSantmann@Wellsoft.com,
Well I don't see how you can possibly get the ActiveTextEditor after the control creation and even after document opening. After you open the document there is no text editor active at all. To see when the text editor is active, you should use the events I mentioned earlier. And again, as I told before:
Cheers,
Alex
Well I don't see how you can possibly get the ActiveTextEditor after the control creation and even after document opening. After you open the document there is no text editor active at all. To see when the text editor is active, you should use the events I mentioned earlier. And again, as I told before:
It's not that difficult to cast a few interfaces.If you are using those events that I previously mentioned then you should get the interface from the parameter - that would assure that you are in the correct document in the correct frame.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 9
- Joined: Wed Mar 29, 2017 1:36 am
Re: Which Form Field Has Focus?
Hi Sasha,
Yes, I see your point, but for my particular situation, ActiveTextEditor seems to works fine.
My situation is as follows:
1) I only have one document at a time (IPXV_Document). I never have two or more instances of IPXV_Document.
2) I think I only have one frame, but I'm honestly not quite sure exactly what a frame is in this context.
3) I am calling ActiveTextEditor from inside a procedure that is only called when triggered by a keystroke which is being captured using IUIX_EventMonitor. In other words, I know a keystroke is being processed, so something is active (i.e. has focus). I don't want to trigger the event when the field first receives focus.
So, I guess I have a question: Is it possible for the end user to type text into a IPXC_FormField without there being an ActiveTextEditor? If not, then I should be OK.
Thanks.
- John
Yes, I see your point, but for my particular situation, ActiveTextEditor seems to works fine.
My situation is as follows:
1) I only have one document at a time (IPXV_Document). I never have two or more instances of IPXV_Document.
2) I think I only have one frame, but I'm honestly not quite sure exactly what a frame is in this context.
3) I am calling ActiveTextEditor from inside a procedure that is only called when triggered by a keystroke which is being captured using IUIX_EventMonitor. In other words, I know a keystroke is being processed, so something is active (i.e. has focus). I don't want to trigger the event when the field first receives focus.
So, I guess I have a question: Is it possible for the end user to type text into a IPXC_FormField without there being an ActiveTextEditor? If not, then I should be OK.
Thanks.
- John
Last edited by JSantmann@Wellsoft.com on Wed Dec 20, 2017 2:36 pm, edited 1 time in total.
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Which Form Field Has Focus?
Hello John,
Cheers,
Alex
With this you have slowed the overall productivity of the API. Doing it the way I suggested would be far more efficient.2) I am calling ActiveTextEditor from inside a procedure that is only called when triggered by a keystroke which is being captured using IUIX_EventMonitor. In other words, I know a keystroke is being processed, so something is active (i.e. has focus).
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 9
- Joined: Wed Mar 29, 2017 1:36 am
Re: Which Form Field Has Focus?
Understood.
Thanks.
Thanks.
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Which Form Field Has Focus?
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ