How input fields work in a published-to-web book:
- If activated = true, then fields are converted to <span> elements in the published book and can be set up to accept click events.
- If activated = false, then fields are converted to <input> or <textarea> elements in the published book and you will not be able to set up a click event on them.
In your project, if are simply trying to ensure which field has focus after a page is loaded, then use this action on the field you want to have the focus:
on load page
pgTBObjSet( name of self, "focus", true, 150); discard return value
If instead you need to know which field your user is inputting text, then use this action on each field:
on key up
set curField to name of self
You may wish to explore the PowerPac function
validateField() as it is designed to monitor/modify the input in editable text fields.
If you really need a click event to fire on an input field, you would probably need to leverage the XML capabilities of the PowerPac as it can do just about anything with your exported content. Here is an XML file which may behave a little like you want. It puts a prompt text in each field on load page and when the user click on a field, it checks whether the prompt text is present and clears it, then ensures the focus is set to the end of the current string of text in the field, if any.
RECOMMENDATION: I would use a focus event instead as that is what the event is designed for. You can see that I've used a focus event on "Field2".
<?xml version="1.0" encoding="utf-8"?>
<page>
<config delay="">
<!--Make sure no field has focus initially-->
<pgTBObjSet>
{ tbName : "Field1", myProp : "focus", myValue : false }
</pgTBObjSet>
<pgTBObjSet>
{ tbName : "Field2", myProp : "focus", myValue : false }
</pgTBObjSet>
</config>
<!--Object name tags follow initial configuration tags.-->
<Field1>
<!--Prompt text to put into the object-->
<text>
<![CDATA[
(Enter your text here.)
]]>
</text>
<function name="myClick" event="click" params="e">
<![CDATA[
/* CLIFTON: This is a click event on an editable text field.
Clear prompt text and keep focus.
***/
var myTxt = tbfunction_pgTBObjGet( this.name, "text" );
if ( myTxt == "(Enter your text here.)" ) {
tbfunction_pgTBObjSet( this.name, "text", "");
}
tbfunction_caretPosition( this.name, "end" );
]]>
</function>
</Field1>
<Field2>
<!--Prompt text to put into the object-->
<text>
<![CDATA[
(Enter your text here.)
]]>
</text>
<function name="myFocus" event="focus" params="e">
<![CDATA[
/* CLIFTON: This is a FOCUS event on an editable text field.
Clear prompt text and keep focus.
***/
var myTxt = tbfunction_pgTBObjGet( this.name, "text" );
if ( myTxt == "(Enter your text here.)" ) {
tbfunction_pgTBObjSet( this.name, "text", "");
}
tbfunction_caretPosition( this.name, "end" );
]]>
</function>
</Field2>
</page>
The above XML file produces the following interactive result: