Skip to main content
Inspiring
April 4, 2025
Answered

How can I make the cursor in a MultilineTextEditBoxWidget move up and down using the arrow keys?

  • April 4, 2025
  • 1 reply
  • 614 views

When I enter multiple lines of text in a MultilineTextEditBoxWidget, I want to be able to move the cursor up and down using the up and down arrow keys. However, currently, the cursor can only move left and right.

I'm not sure if this is due to a missing parameter setting or if the MultilineTextEditBoxWidget provided by the SDK does not support this functionality. However, I noticed that in InDesign's PDF Export dialog, the multiline input field already supports this behavior.

Correct answer Dirk Becker
EVEMyMultilineTextEditBoxWidget// Watermark text field
(
kMyeditboxWidgetID, // WidgetId
kSysEditBoxPMRsrcId, // RsrcId
kBindLeft | kBindRight ,
Frame(0,0,200,200) // Frame
kTrue, kTrue, // Visible, Enabled
0, // widget id of nudge button
1, // small nudge amount
10, // large nudge amount
0, // max num chars(0 = no limit)
kFalse, // is read only
kTrue, // should notify each key stroke (NEW)
kFalse, // range checking enabled
kFalse, // blank entry allowed
0,
0, // upper/lower bounds
"", // initial text
kEVENoSpaceAfter| kEVEAlignFill,
),     
this is  my editbox  code at .fr.  and I develop  plugin at windows

Differences:

kBindNone

large nudge = 0

upper bounds = 100

notify keystrokes = false

 

Plenty speculation ahead:

 

My guess is the notify keystrokes flag. kTrue is rare in the SDK examples, and I doubt it is intentional for kSpellAlternativeEditBoxID. Could be the key strokes are absorbed with this flag.

Given the (NEW) comment, I assume you copied it from kPDFVTUIDataSourceFileTextWidgetID or kWatermarkUIEditBoxWidgetID. Have you tried with false as I already suggested above?

 

Otherwise it could be some extra setup code, maybe using a private Drover call. Once upon a time IControlView had a getter for the SysControl / HWND so we could look at the Windows side, but that's gone. If I were desperate I'd try Windows API such as EnumChildWindows() and dig deeper from there.

 

If you only need the key strokes to update a related display, you could also watch InDesign's events. To learn about focus / blur, observe your kMyeditboxWidgetID for protocol IID_IEVENTHANDLER, message is kEditBoxGetKeyFocusMessage or kEditBoxGiveUpKeyFocusMessage. Between those, register/unregister an IEventWatcher at IEventDispatcher. Works at least here on the Mac.

 

There is also a very old "filter" programming pattern to subclass the boss class, move the event handler implementation to another IID (any of yours will do) and provide your own event handler that passes on most calls. Somewhere deep in the SDK it is mentioned that event handlers are discouraged, so you better also stay away from that.

 

1 reply

lyj2871Author
Inspiring
April 8, 2025

As shown in the image, the multi-line text box in this PDF export dialog supports moving the cursor up and down using the arrow keys. I defined the following type:

 

cpp
复制编辑
type EVEMyMultilineTextEditBoxWidget(kViewRsrcType) : EVEMultilineTextEditBoxWidget(ClassID = kTextEditBoxWidgetBoss) { };
 

However, when I define my edit box control using the EVEMyMultilineTextEditBoxWidget type and input multiple lines of text, the cursor is actually not able to move up and down using the arrow keys.

Does anyone know which k...Boss I should use to enable this functionality?

Robert at ID-Tasker
Brainiac
April 8, 2025

Tagging @Dirk Becker