From 6004960398b36a83d05c068ee633591b855b2c0b Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Fri, 19 Oct 2012 13:46:37 +0200 Subject: [PATCH] Deselect first char in Move Type-in and ICS Input Box After popup the Move Type-In had the typed character in it, but it was selected, so that typing a second character would erase it again. Same for the ICS Input Box. A prototype for CursorAtEnd is now also added. --- dialogs.c | 2 ++ dialogs.h | 1 + xoptions.c | 6 ++++++ 3 files changed, 9 insertions(+), 0 deletions(-) diff --git a/dialogs.c b/dialogs.c index 6455f74..22577e7 100644 --- a/dialogs.c +++ b/dialogs.c @@ -1181,6 +1181,7 @@ ICSInputBoxPopUp () MarkMenu("View.ICSInputBox", InputBoxDlg); if(GenericPopUp(boxOptions, _("ICS input box"), InputBoxDlg, BoardWindow, NONMODAL, 0)) AddHandler(&boxOptions[0], InputBoxDlg, 3); + CursorAtEnd(&boxOptions[0]); } void @@ -1212,6 +1213,7 @@ PopUpMoveDialog (char firstchar) buf[0] = firstchar; ASSIGN(icsText, buf); if(GenericPopUp(typeOptions, _("Type a move"), TransientDlg, BoardWindow, MODAL, 0)) AddHandler(&typeOptions[0], TransientDlg, 2); + CursorAtEnd(&typeOptions[0]); } void diff --git a/dialogs.h b/dialogs.h index d77708b..6c3c201 100644 --- a/dialogs.h +++ b/dialogs.h @@ -142,6 +142,7 @@ void SetColor P((char *colorName, Option *box)); //void ColorChanged P((Widget w, XtPointer data, XEvent *event, Boolean *b)); void SetInsertPos P((Option *opt, int pos)); void HardSetFocus P((Option *opt)); +void CursorAtEnd P((Option *opt)); void GetWidgetText P((Option *opt, char **buf)); void SetWidgetText P((Option *opt, char *buf, int n)); void GetWidgetState P((Option *opt, int *state)); diff --git a/xoptions.c b/xoptions.c index e952b52..583ab9d 100644 --- a/xoptions.c +++ b/xoptions.c @@ -449,6 +449,12 @@ char *translationTable[] = { // beware: order is essential! Option *typeIn; // kludge to distinguish type-in callback from input-box callback +void +CursorAtEnd (Option *opt) +{ + gtk_editable_set_position(opt->handle, -1); +} + static gboolean ICSKeyEvent(GtkWidget *widget, GdkEventKey *event, gpointer g) { -- 1.7.0.4