Example #1
0
static int KeyPressCallback(txt_window_t *window, int key, 
                            TXT_UNCAST_ARG(key_input))
{
    TXT_CAST_ARG(txt_key_input_t, key_input);

    if (key != KEY_ESCAPE)
    {
        // Got the key press.  Save to the variable and close the window.

        *key_input->variable = key;

        if (key_input->check_conflicts)
        {
            TXT_EmitSignal(key_input, "set");
        }

        TXT_CloseWindow(window);

        // Re-enable key mappings now that we have the key

        TXT_EnableKeyMapping(1);

        return 1;
    }
    else
    {
        return 0;
    }
}
Example #2
0
static void OpenPromptWindow(txt_key_input_t *key_input)
{
    txt_window_t *window;
    txt_label_t *label;

    // Silently update when the shift button is held down.

    key_input->check_conflicts = !TXT_GetModifierState(TXT_MOD_SHIFT);

    window = TXT_NewWindow(NULL);
    TXT_SetWindowAction(window, TXT_HORIZ_LEFT, NULL);
    TXT_SetWindowAction(window, TXT_HORIZ_CENTER, 
                        TXT_NewWindowAbortAction(window));
    TXT_SetWindowAction(window, TXT_HORIZ_RIGHT, NULL);
    
    label = TXT_NewLabel("Press the new key...");

    TXT_AddWidget(window, label);
    TXT_SetWidgetAlign(label, TXT_HORIZ_CENTER);

    TXT_SetKeyListener(window, KeyPressCallback, key_input);

    // Disable key mappings while we prompt for the key press

    TXT_EnableKeyMapping(0);

    // Grab input while reading the key.  On Windows Mobile
    // handheld devices, the hardware keypresses are only
    // detected when input is grabbed.

    SDL_WM_GrabInput(SDL_GRAB_ON);
    TXT_SignalConnect(window, "closed", ReleaseGrab, NULL);
}
Example #3
0
static void OpenPromptWindow(txt_key_input_t *key_input)
{
    txt_window_t *window;

    // Silently update when the shift button is held down.

    key_input->check_conflicts = !TXT_GetModifierState(TXT_MOD_SHIFT);

    window = TXT_MessageBox(NULL, "Press the new key...");

    TXT_SetKeyListener(window, KeyPressCallback, key_input);

    // Disable key mappings while we prompt for the key press

    TXT_EnableKeyMapping(0);

    // Grab input while reading the key.  On Windows Mobile
    // handheld devices, the hardware keypresses are only
    // detected when input is grabbed.

    SDL_WM_GrabInput(SDL_GRAB_ON);
    TXT_SignalConnect(window, "closed", ReleaseGrab, NULL);
}