summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCamil Staps2019-10-25 20:13:34 +0200
committerCamil Staps2019-10-25 20:13:34 +0200
commit4b0b45283080cf5d48794039a673247e69bb7867 (patch)
treeec53c918b30cf91161d6bf6bb53327c37c93d0f2
parentAdd G modifier to ccalls that may trigger GTK signals (which may cause re-ent... (diff)
Catch traverse event to (-1,0) which seems to be a bug in GtkSheet
-rw-r--r--src/Gtk/State.dcl2
-rw-r--r--src/Gtk/Widgets/Sheet/Signal.icl20
2 files changed, 14 insertions, 8 deletions
diff --git a/src/Gtk/State.dcl b/src/Gtk/State.dcl
index cbc86c1..7e56fcf 100644
--- a/src/Gtk/State.dcl
+++ b/src/Gtk/State.dcl
@@ -15,7 +15,7 @@ from Gtk.Signal import :: SignalHandlerInternal
, return :: !Bool
, signal_handlers :: !Map Int SignalHandlerInternal
, signal_counter :: !Int
- , shares :: !Map ShareId Dynamic
+ , shares :: !Map ShareId Dynamic // TODO: make this map strict to be able to free references in it
}
:: GtkM a =: GtkM (GtkState -> (a, GtkState))
diff --git a/src/Gtk/Widgets/Sheet/Signal.icl b/src/Gtk/Widgets/Sheet/Signal.icl
index adc6054..6db3b6b 100644
--- a/src/Gtk/Widgets/Sheet/Signal.icl
+++ b/src/Gtk/Widgets/Sheet/Signal.icl
@@ -18,10 +18,16 @@ where
EnterPressedHandler f -> SHI_Pointer_Bool \_ -> not <$> f
TraverseHandler f -> SHI_Int_Int_Pointer_Pointer_Bool \oldrow oldcol newrowp newcolp ->
let newrow = readInt4S newrowp 0; newcol = readInt4S newcolp 0 in
- f (if (oldrow<0) Nothing (Just (oldrow,oldcol))) (newrow,newcol) >>= \r -> case r of
- Nothing ->
- pure False
- Just (row,col) ->
- appWorld (forceEval (writeInt4 newrowp 0 row)) >>|
- appWorld (forceEval (writeInt4 newcolp 0 col)) >>|
- pure True
+ // NB, possible bug in GtkSheet: when a cell is selected and the
+ // user then presses enter, this emits a traverse signal with new
+ // location (-1,0), and selects the entire first column. This seems
+ // undesirable, so we prevent it.
+ if (newrow < 0 || newcol < 0)
+ (pure False)
+ (f (if (oldrow<0) Nothing (Just (oldrow,oldcol))) (newrow,newcol) >>= \r -> case r of
+ Nothing ->
+ pure False
+ Just (row,col) ->
+ appWorld (forceEval (writeInt4 newrowp 0 row)) >>|
+ appWorld (forceEval (writeInt4 newcolp 0 col)) >>|
+ pure True)