Note that there are some explanatory texts on larger screens.

plurals
  1. POWindows.h - Notification when focus enters a text input
    primarykey
    data
    text
    <p>I'm trying to come up with a solution for setting up a notification when focus enters a text field. The end goal in mind is to recreate the type of functionality you see on mobile devices with on screen keyboards.</p> <p>So far I've been exploring <code>SetWinEventHook</code> with <code>EVENT_OBJECT_FOCUS</code> and <code>GetGUIThreadInfo</code> with <code>GUI_CARETBLINKING</code>. </p> <p>From the docs:</p> <blockquote> <p>EVENT_OBJECT_FOCUS</p> <p>An object has received the keyboard focus. The system sends this event for the following user interface elements: list-view control, menu bar, pop-up menu, switch window, tab control, tree view control, and window object.</p> <p>GUI_CARETBLINKING The caret's blink state. This bit is set if the caret is visible.</p> </blockquote> <p>Using these methods I've come up with this solution:</p> <pre><code>void TextInputHelper::setupEventHook(FREContext iCtx) { ctx = iCtx; CoInitialize(NULL); evHook = SetWinEventHook(EVENT_OBJECT_FOCUS, EVENT_OBJECT_END, NULL, handleEventObjectFocus, 0, 0, WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS); } void CALLBACK handleEventObjectFocus(HWINEVENTHOOK hook, DWORD evt, HWND hwnd, LONG idObj, LONG idChild, DWORD thread, DWORD time) { GUITHREADINFO threadInfo; threadInfo.cbSize = sizeof(GUITHREADINFO); BOOL result = GetGUIThreadInfo(thread, &amp;threadInfo); if(threadInfo.flags &amp; GUI_CARETBLINKING) { //text field focus } } </code></pre> <p>This does seem to work in some cases but its definitely not reliable. Programs like Notepad an IE seem to work fine but others like Firefox do not. This also will not work for things like text fields on websites because it doesn't look like <code>handleEventObjectFocus</code> will get called.</p> <p>Does anyone know of another way to approach this problem? I've been searching around and it seems like I might be looking for something in the Accessibility APIs but I haven't been able to dig up to much on it.</p> <p>Thanks!</p> <p><strong>edit</strong></p> <p>To clarify, I'm looking to receive a notification when focus enters any text field. This application is a win32 dll and will never have focus its self.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload