From b95ff408cd8cf048530d9dc4ef3b86127bc76ddd Mon Sep 17 00:00:00 2001 From: gambas Date: Fri, 16 Apr 2021 04:24:22 +0200 Subject: [PATCH] Focus navigation works again. [GB.GTK] * BUG: Focus navigation works again. [GB.GTK3] * BUG: Focus navigation works again. --- gb.gtk/src/gcontrol.cpp | 2 +- gb.gtk/src/gcontrol.h | 2 +- gb.gtk/src/gsignals.cpp | 12 ++++++++---- gb.gtk/src/gtextarea.cpp | 32 ++++++++++++++++---------------- gb.gtk/src/gtextarea.h | 33 ++++++++++++++++----------------- 5 files changed, 42 insertions(+), 39 deletions(-) diff --git a/gb.gtk/src/gcontrol.cpp b/gb.gtk/src/gcontrol.cpp index b717a7190..1b9397f7b 100644 --- a/gb.gtk/src/gcontrol.cpp +++ b/gb.gtk/src/gcontrol.cpp @@ -2051,7 +2051,7 @@ void gControl::updateBorder() //gtk_widget_queue_draw(frame); } -int gControl::getFrameWidth() +int gControl::getFrameWidth() const { guint p; diff --git a/gb.gtk/src/gcontrol.h b/gb.gtk/src/gcontrol.h index 255858b12..23504b452 100644 --- a/gb.gtk/src/gcontrol.h +++ b/gb.gtk/src/gcontrol.h @@ -336,7 +336,7 @@ public: bool hasBorder() const; int getFramePadding() const { return frame_padding; } void setFramePadding(int padding); - virtual int getFrameWidth(); + virtual int getFrameWidth() const; virtual gColor getFrameColor(); #ifdef GTK3 void drawBorder(cairo_t *cr); diff --git a/gb.gtk/src/gsignals.cpp b/gb.gtk/src/gsignals.cpp index 1efb603aa..701ba9bc2 100644 --- a/gb.gtk/src/gsignals.cpp +++ b/gb.gtk/src/gsignals.cpp @@ -77,12 +77,16 @@ gboolean gcb_focus(GtkWidget *widget, GtkDirectionType direction, gControl *data { gControl *ctrl; - if (data != gApplication::activeControl()) - return true; - if (direction == GTK_DIR_TAB_FORWARD || direction == GTK_DIR_TAB_BACKWARD) { - ctrl = data; + ctrl = gApplication::activeControl(); + + if (!ctrl) + return true; + + if (ctrl->topLevel() != data) + return true; + for(;;) { //fprintf(stderr, "cb_focus: %s / %d %d\n", ctrl->name(), ctrl->isEnabled(), ctrl->canFocus()); diff --git a/gb.gtk/src/gtextarea.cpp b/gb.gtk/src/gtextarea.cpp index 2a9f03be0..7e5d6675d 100644 --- a/gb.gtk/src/gtextarea.cpp +++ b/gb.gtk/src/gtextarea.cpp @@ -544,7 +544,7 @@ gTextArea::~gTextArea() clearUndoStack(); } -char *gTextArea::text() +char *gTextArea::text() const { GtkTextIter start; GtkTextIter end; @@ -571,7 +571,7 @@ void gTextArea::setText(const char *txt, int len) end(); } -bool gTextArea::readOnly() +bool gTextArea::readOnly() const { return !gtk_text_view_get_editable(GTK_TEXT_VIEW(textview)); } @@ -583,7 +583,7 @@ void gTextArea::setReadOnly(bool vl) _eat_return_key = !vl; } -GtkTextIter *gTextArea::getIterAt(int pos) +GtkTextIter *gTextArea::getIterAt(int pos) const { static GtkTextIter iter; @@ -595,7 +595,7 @@ GtkTextIter *gTextArea::getIterAt(int pos) return &iter; } -int gTextArea::line() +int gTextArea::line() const { return gtk_text_iter_get_line(getIterAt()); } @@ -624,7 +624,7 @@ void gTextArea::setLine(int vl) ensureVisible(); } -int gTextArea::column() +int gTextArea::column() const { return gtk_text_iter_get_line_offset(getIterAt()); } @@ -648,7 +648,7 @@ void gTextArea::setColumn(int vl) ensureVisible(); } -int gTextArea::position() +int gTextArea::position() const { return gtk_text_iter_get_offset(getIterAt()); } @@ -662,7 +662,7 @@ void gTextArea::setPosition(int vl) ensureVisible(); } -int gTextArea::length() +int gTextArea::length() const { GtkTextIter iter; @@ -670,7 +670,7 @@ int gTextArea::length() return gtk_text_iter_get_offset(&iter); } -bool gTextArea::wrap() +bool gTextArea::wrap() const { return (gtk_text_view_get_wrap_mode(GTK_TEXT_VIEW(textview)) != GTK_WRAP_NONE); } @@ -725,7 +725,7 @@ void gTextArea::insert(const char *txt) gtk_text_buffer_insert_at_cursor(_buffer, (const gchar *)txt, -1); } -int gTextArea::toLine(int pos) +int gTextArea::toLine(int pos) const { if (pos < 0) pos=0; @@ -735,7 +735,7 @@ int gTextArea::toLine(int pos) return gtk_text_iter_get_line(getIterAt(pos)); } -int gTextArea::toColumn(int pos) +int gTextArea::toColumn(int pos) const { if (pos < 0) pos=0; @@ -745,7 +745,7 @@ int gTextArea::toColumn(int pos) return gtk_text_iter_get_line_offset(getIterAt(pos)); } -int gTextArea::toPosition(int line, int col) +int gTextArea::toPosition(int line, int col) const { GtkTextIter iter; int lm, cm; @@ -779,13 +779,13 @@ gTextArea selection ***********************************************************************************/ -bool gTextArea::isSelected() +bool gTextArea::isSelected() const { return gtk_text_buffer_get_selection_bounds(_buffer, NULL, NULL); //return gtk_text_buffer_get_has_selection(buf); // Only since 2.10 } -int gTextArea::selStart() +int gTextArea::selStart() const { GtkTextIter start, end; @@ -793,7 +793,7 @@ int gTextArea::selStart() return gtk_text_iter_get_offset(&start); } -int gTextArea::selEnd() +int gTextArea::selEnd() const { GtkTextIter start, end; @@ -801,7 +801,7 @@ int gTextArea::selEnd() return gtk_text_iter_get_offset(&end); } -char *gTextArea::selText() +char *gTextArea::selText() const { GtkTextIter start, end; char *text; @@ -1091,7 +1091,7 @@ void gTextArea::customStyleSheet(GString *) #endif -void gTextArea::getCursorPos(int *x, int *y, int pos) +void gTextArea::getCursorPos(int *x, int *y, int pos) const { GdkRectangle rect; int f = getFrameWidth(); diff --git a/gb.gtk/src/gtextarea.h b/gb.gtk/src/gtextarea.h index cbae59271..b40792bf0 100644 --- a/gb.gtk/src/gtextarea.h +++ b/gb.gtk/src/gtextarea.h @@ -33,14 +33,14 @@ public: ~gTextArea(); //"Properties" - int column(); - int length(); - int line(); - int position(); - bool readOnly(); - char* text(); - bool wrap(); - bool isSelected(); + int column() const; + int length() const; + int line() const; + int position() const; + bool readOnly() const; + char* text() const; + bool wrap() const; + bool isSelected() const; void setColumn(int vl); void setLine(int vl); @@ -48,7 +48,6 @@ public: void setReadOnly(bool vl); void setText(const char *txt, int len = -1); void setWrap(bool vl); - //int textWidth(); //int textHeight(); @@ -61,14 +60,14 @@ public: void ensureVisible(); void paste(); void insert(const char *txt); - int toLine(int pos); - int toColumn(int pos); - int toPosition(int line, int col); + int toLine(int pos) const; + int toColumn(int pos) const; + int toPosition(int line, int col) const; //"Selection properties" - int selStart(); - int selEnd(); - char* selText(); + int selStart() const; + int selEnd() const; + char* selText() const; void setSelText(const char *vl); @@ -85,7 +84,7 @@ public: void redo(); void clear(); - void getCursorPos(int *x, int *y, int pos); + void getCursorPos(int *x, int *y, int pos) const; void emitCursor(); @@ -124,7 +123,7 @@ private: int _last_pos; GtkTextTag *_fix_spacing_tag; - GtkTextIter *getIterAt(int pos = -1); + GtkTextIter *getIterAt(int pos = -1) const; }; #endif