The window close events for all non-modal windows (but no modal windows) get passed to APP_CUSTOM.CLOSE_WINDOW. The default code provided in the TEMPLATE form does the following:
If the form is in enter-query mode, APP_CUSTOM calls
APP_EXCEPTION.DISABLED
Otherwise, if the cursor is currently in the window to be closed, APP_CUSTOM issues a do_key('PREVIOUS_BLOCK') to attempt to move the cursor out of the current window
Finally, APP_CUSTOM hides the window with a call to HIDE_WINDOW('<window_name>').
You need to modify this procedure to account for any other behaviors you require. Specifically, modify it to handle block coordination issues and detail windows.
Remember that you must move the cursor out of the window before closing it, otherwise the window reopens automatically.
To close the first window of a form, which is equivalent to "File->Close Form" call APP_WINDOW.CLOSE_FIRST_WINDOW.
ExampleIn a form with windows "Header," "Lines," and "Shipments," where Lines is a detail of Header, and Shipments is a detail of Lines, the logic to close the windows is as follows:
PROCEDURE close_window (wnd VARCHAR2) IS
IF wnd = 'HEADER' THEN
--
-- Exit the form
--
app_window.close_first_window;
ELSIF wnd = 'LINES' THEN
--
-- Close detail windows (Shipments)
--
app_custom.close_window('SHIPMENTS');
--
-- If cursor is in this window,
-- move it to the HEADER block
--
IF (wnd = GET_VIEW_PROPERTY(GET_ITEM_PROPERTY(
:SYSTEM.CURSOR_ITEM,ITEM_CANVAS),
WINDOW_NAME)) THEN
GO_BLOCK('HEADER');
END IF;
ELSIF wnd = 'SHIPMENTS' THEN
--
-- If cursor is in this window,
-- move it to the LINES block
--
IF (wnd = GET_VIEW_PROPERTY(GET_ITEM_PROPERTY(
:SYSTEM.CURSOR_ITEM, ITEM_CANVAS),
WINDOW_NAME)) THEN
GO_BLOCK('LINES');
END IF;
END IF;
--
-- THIS CODE MUST REMAIN HERE. It ensures
-- the cursor is not in the window that will
-- be closed by moving it to the previous block.
--
IF (wnd = GET_VIEW_PROPERTY(GET_ITEM_PROPERTY(
:SYSTEM.CURSOR_ITEM, ITEM_CANVAS),
WINDOW_NAME)) THEN
DO_KEY('PREVIOUS_BLOCK');
END IF;
--
-- Now actually close the designated window
--
HIDE_WINDOW(wnd);
END close_window;
Warning: You must leave the default clause that attempts to move the cursor and close the window name passed to this procedure.