Hot Door CORE Forum
Keyboard press event in textframe - Printable Version

+- Hot Door CORE Forum (http://hotdoorcore.com/forum)
+-- Forum: All forums (http://hotdoorcore.com/forum/forumdisplay.php?fid=1)
+--- Forum: Getting started (http://hotdoorcore.com/forum/forumdisplay.php?fid=6)
+--- Thread: Keyboard press event in textframe (/showthread.php?tid=52)



Keyboard press event in textframe - vinothjaguva - 07-23-2015

Hi

I want to detect key press event to prevent the modification except CR and TAB in the existing text frame, and if the user did the modification, at the same time i want to revert back(undo).

Thanks in Advance.

Vinoth V.

Wink


RE: Keyboard press event in textframe - garrett - 07-23-2015

You should be able to accomplish this by setting a value-changing event callback on the text field (or text view) with the setValueChangingCallback() method. Then, your callback should execute every time the user types a character into the field/view. During the execution of a value-changing callback, the method lastCharTyped() can be used to determine what the user has just typed. You can then use that information within the callback to enforce whatever restrictions you'd like.


RE: Keyboard press event in textframe - vinothjaguva - 07-23-2015

(07-23-2015, 11:45 AM)garrett Wrote: You should be able to accomplish this by setting a value-changing event callback on the text field (or text view) with the setValueChangingCallback() method. Then, your callback should execute every time the user types a character into the field/view. During the execution of a value-changing callback, the method lastCharTyped() can be used to determine what the user has just typed. You can then use that information within the callback to enforce whatever restrictions you'd like.

Hi

Thank you so much for your quick reply. Text frame I meant is AI text frame not plug-ins text field. Can I get any advise on this.


RE: Keyboard press event in textframe - garrett - 07-27-2015

Oh I see. Sorry for the confusion.

I cannot think of any "clean" way to accomplish this. There is no notifier for text art being edited (i.e. something like TextFrameBeginEditingNotifierType does not exist). If there were, you could watch for that notification and then enable a keystroke monitor, which would possibly enforce whatever restrictions necessary. Once the notifier for the text editing ending is fired (which, again, does not exist) you would disable the keystroke monitor(s).

So, at this point, without those notifiers, I don't think it's possible to do what you want. You could use the notifier ToolSelectedNotifierType to determine when the relevant text tools have been selected (and ToolDeselectedNotifierType for when they are deselected), but that still won't tell you when text editing has actually begun.


RE: Keyboard press event in textframe - vinothjaguva - 07-28-2015

(07-27-2015, 08:18 AM)garrett Wrote: Oh I see. Sorry for the confusion.

I cannot think of any "clean" way to accomplish this. There is no notifier for text art being edited (i.e. something like TextFrameBeginEditingNotifierType does not exist). If there were, you could watch for that notification and then enable a keystroke monitor, which would possibly enforce whatever restrictions necessary. Once the notifier for the text editing ending is fired (which, again, does not exist) you would disable the keystroke monitor(s).

So, at this point, without those notifiers, I don't think it's possible to do what you want. You could use the notifier ToolSelectedNotifierType to determine when the relevant text tools have been selected (and ToolDeselectedNotifierType for when they are deselected), but that still won't tell you when text editing has actually begun.

Hi

Thank you so much for your reply. Really appreciating your quick response.

Is there anyway to find key press is happen in the text frame(ai), example if the user press "A" can we get alert the keyboard "A" is pressed.

Thanks in Advance


RE: Keyboard press event in textframe - garrett - 07-28-2015

Well, as I was saying, you could register a keystroke monitor using hdi::core:Big Grinispatcher::addKeypressMonitor(), but there is no way to ensure that the keystroke callback is being fired within the scope of the user editing an AI text frame.