# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1349752125 0 # Node ID 9bbe090d0250904072068ba1dd0efe7fd00197a6 # Parent e7ed7bbea3a4c6388db7aaa29d85cab981ea538b Depending on the tab direction on Windows, the dual purpose notebook control needs to be handled in a different order when being input and box. diff -r e7ed7bbea3a4 -r 9bbe090d0250 win/dw.c --- a/win/dw.c Mon Oct 08 23:51:45 2012 +0000 +++ b/win/dw.c Tue Oct 09 03:08:45 2012 +0000 @@ -958,6 +958,8 @@ #define _DW_DIRECTION_FORWARD -1 #define _DW_DIRECTION_BACKWARD 1 +int _focus_check_box(Box *box, HWND handle, int start, int direction, HWND defaultitem); + /* Internal comparision function */ int _focus_comp(int direction, int z, int end) { @@ -966,6 +968,26 @@ return z < end; } +int _focus_notebook(HWND hwnd, HWND handle, int start, int direction, HWND defaultitem) +{ + NotebookPage **array = (NotebookPage **)dw_window_get_data(hwnd, "_dw_array"); + int pageid = TabCtrl_GetCurSel(hwnd); + + if(pageid > -1 && array && array[pageid]) + { + Box *notebox; + + if(array[pageid]->hwnd) + { + notebox = (Box *)GetWindowLongPtr(array[pageid]->hwnd, GWLP_USERDATA); + + if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0, direction, defaultitem)) + return 1; + } + } + return 0; +} + /* Handle box focus traversal in either direction */ int _focus_check_box(Box *box, HWND handle, int start, int direction, HWND defaultitem) { @@ -1008,8 +1030,11 @@ } else { - int type; + int type = _validate_focus(box->items[z].hwnd); + /* Special case notebook, can focus and contains items */ + if(type == 2 && direction == _DW_DIRECTION_FORWARD && _focus_notebook(box->items[z].hwnd, handle, start, direction, defaultitem)) + return 1; if(box->items[z].hwnd == handle) { if(lasthwnd == handle && firsthwnd) @@ -1025,7 +1050,7 @@ if(!finish_searching) return 1; } - if((type = _validate_focus(box->items[z].hwnd)) != 0) + if(type > 0) { /* Start is 3 when we are looking for the * first valid item in the layout. @@ -1085,24 +1110,8 @@ } } /* Special case notebook, can focus and contains items */ - if(type == 2 && box->items[z].hwnd != handle) - { - NotebookPage **array = (NotebookPage **)dw_window_get_data(box->items[z].hwnd, "_dw_array"); - int pageid = TabCtrl_GetCurSel(box->items[z].hwnd); - - if(pageid > -1 && array && array[pageid]) - { - Box *notebox; - - if(array[pageid]->hwnd) - { - notebox = (Box *)GetWindowLongPtr(array[pageid]->hwnd, GWLP_USERDATA); - - if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0, direction, defaultitem)) - return 1; - } - } - } + if(type == 2 && direction == _DW_DIRECTION_BACKWARD && _focus_notebook(box->items[z].hwnd, handle, start, direction, defaultitem)) + return 1; } } return 0;