Mercurial > dwindows
comparison android/DWindows.kt @ 2670:e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
Move the window destroy logic into the C code event handler...
That way handling the DW_SIGNAL_DELETE can prevent the window closure.
The application still can't be stopped from closing, but windows can.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 18 Oct 2021 00:09:57 +0000 |
parents | 2ad924c6493d |
children | a7868380098f |
comparison
equal
deleted
inserted
replaced
2669:2ad924c6493d | 2670:e3a95940c18f |
---|---|
972 override fun onBackPressed() { | 972 override fun onBackPressed() { |
973 if(windowLayout != null) { | 973 if(windowLayout != null) { |
974 val adapter: DWTabViewPagerAdapter = windowLayout!!.adapter as DWTabViewPagerAdapter | 974 val adapter: DWTabViewPagerAdapter = windowLayout!!.adapter as DWTabViewPagerAdapter |
975 val index = windowLayout!!.currentItem | 975 val index = windowLayout!!.currentItem |
976 | 976 |
977 if (index > 0) { | 977 // If the current window has a close button... |
978 windowDestroy(adapter.viewList[index]) | 978 if (index > 0 && (windowStyles[index] and 1) == 1) { |
979 // Send the DW_SIGNAL_DELETE to the event handler | |
980 eventHandlerSimple(adapter.viewList[index], DWEvent.DELETE) | |
979 } | 981 } |
980 } | 982 } |
981 } | 983 } |
982 | 984 |
983 // These are the Android calls to actually create the UI... | 985 // These are the Android calls to actually create the UI... |
1145 // If this is our first/only window... | 1147 // If this is our first/only window... |
1146 // We can set stuff immediately | 1148 // We can set stuff immediately |
1147 if (adapter.viewList.count() == 1) { | 1149 if (adapter.viewList.count() == 1) { |
1148 this.title = title | 1150 this.title = title |
1149 windowLayout!!.setCurrentItem(0, false) | 1151 windowLayout!!.setCurrentItem(0, false) |
1152 if((windowStyles[0] and 2) != 2) { | |
1153 supportActionBar?.hide() | |
1154 } | |
1150 } | 1155 } |
1151 } | 1156 } |
1152 } | 1157 } |
1153 return window | 1158 return window |
1154 } | 1159 } |
1422 } | 1427 } |
1423 // This is how I prefered to do it, but it doesn't work... | 1428 // This is how I prefered to do it, but it doesn't work... |
1424 // So using RecyclerView.scrollToPosition() also | 1429 // So using RecyclerView.scrollToPosition() also |
1425 windowLayout!!.setCurrentItem(index, true) | 1430 windowLayout!!.setCurrentItem(index, true) |
1426 | 1431 |
1432 // Hide or show the actionbar based on the titlebar flag | |
1433 if((windowStyles[index] and 2) == 2) { | |
1434 supportActionBar?.show() | |
1435 } else { | |
1436 supportActionBar?.hide() | |
1437 } | |
1427 // If the new view has a default item, focus it | 1438 // If the new view has a default item, focus it |
1428 if(windowDefault[index] != null) { | 1439 if(windowDefault[index] != null) { |
1429 windowDefault[index]?.requestFocus() | 1440 windowDefault[index]?.requestFocus() |
1430 } | 1441 } |
1431 // Add or remove a back button depending on the visible window | 1442 // Add or remove a back button depending on the visible window |
1432 if(index > 0) { | 1443 if(index > 0 && (windowStyles[index] and 1) == 1) { |
1433 this.actionBar?.setDisplayHomeAsUpEnabled(true) | 1444 this.actionBar?.setDisplayHomeAsUpEnabled(true) |
1434 } else { | 1445 } else { |
1435 this.actionBar?.setDisplayHomeAsUpEnabled(false) | 1446 this.actionBar?.setDisplayHomeAsUpEnabled(false) |
1436 } | 1447 } |
1437 // Invalidate the menu, so it gets updated for the new window | 1448 // Invalidate the menu, so it gets updated for the new window |