From 56824b130b786aab49876a71c6c768a17c5a4f1c Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 10 Dec 2010 20:31:46 +0000 Subject: Replace txt_widget_t#selectable with a callback function to query whether the widget is selectable. This stops the table code from selecting things that aren't really selectable - eg. empty tables, scrollpanes containing unselectable widgets, etc. Fixes a bug with the warp menu (thanks Proteh). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2207 --- textscreen/txt_scrollpane.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'textscreen/txt_scrollpane.c') diff --git a/textscreen/txt_scrollpane.c b/textscreen/txt_scrollpane.c index d81cce4b..17c9bcbf 100644 --- a/textscreen/txt_scrollpane.c +++ b/textscreen/txt_scrollpane.c @@ -138,7 +138,7 @@ static void TXT_ScrollPaneSizeCalc(TXT_UNCAST_ARG(scrollpane)) } if (scrollpane->expand_h) { - scrollpane->h = FullWidth(scrollpane); + scrollpane->h = FullHeight(scrollpane); } scrollpane->widget.w = scrollpane->w; @@ -486,8 +486,26 @@ static void TXT_ScrollPaneLayout(TXT_UNCAST_ARG(scrollpane)) } } +static int TXT_ScrollPaneSelectable(TXT_UNCAST_ARG(scrollpane)) +{ + TXT_CAST_ARG(txt_scrollpane_t, scrollpane); + + // If scroll bars are displayed, the scroll pane must be selectable + // so that we can use the arrow keys to scroll around. + + if (NeedsScrollbars(scrollpane)) + { + return 1; + } + + // Otherwise, whether this is selectable depends on the child widget. + + return TXT_SelectableWidget(scrollpane->child); +} + txt_widget_class_t txt_scrollpane_class = { + TXT_ScrollPaneSelectable, TXT_ScrollPaneSizeCalc, TXT_ScrollPaneDrawer, TXT_ScrollPaneKeyPress, -- cgit v1.2.3