Index: trunk/Assembly_Library/Inc/MenuEvents.inc
===================================================================
--- trunk/Assembly_Library/Inc/MenuEvents.inc	(revision 55)
+++ trunk/Assembly_Library/Inc/MenuEvents.inc	(revision 58)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	13.7.2010
-; Last update	:	5.10.2010
+; Last update	:	18.10.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Defines for Menu events send to the user.
@@ -28,4 +28,7 @@
 	; Parameters:
 	;	None
+	; Returns:
+	;	CF:			Set to exit menu
+	;				Clear to cancel exit
 	.ExitMenu						resb	2
 
Index: trunk/Assembly_Library/Src/LibraryTests.asm
===================================================================
--- trunk/Assembly_Library/Src/LibraryTests.asm	(revision 55)
+++ trunk/Assembly_Library/Src/LibraryTests.asm	(revision 58)
@@ -136,5 +136,5 @@
 ALIGN WORD_ALIGN
 .rgfnSelectionHandler:
-	dw		.ExitMenu
+	dw		.ExitMenuByItem
 	dw		.ToggleTitle
 	dw		.ToggleInfo
@@ -148,6 +148,7 @@
 
 ALIGN JUMP_ALIGN
-.ExitMenu:
+.ExitMenuByItem:
 	CALL_MENU_LIBRARY Close
+.ExitMenuByMenuLibrary:
 	stc
 	ret
@@ -317,13 +318,13 @@
 ALIGN WORD_ALIGN
 .rgfnMenuEvents:
-	dw		.InitializeMenu		; .InitializeMenuinitToDSSI
-	dw		.NotHandled			; .ExitMenu
-	dw		.NotHandled			; .IdleProcessing
-	dw		.NotHandled			; .ItemHighlightedFromCX
-	dw		.ItemSelectedFromCX	; .ItemSelectedFromCX
-	dw		.NotHandled			; .KeyStrokeInDX
-	dw		.RefreshTitle		; .RefreshTitle
-	dw		.RefreshInformation	; .RefreshInformation
-	dw		.RefreshItemFromCX	; .RefreshItemFromCX
+	dw		.InitializeMenu			; .InitializeMenuinitToDSSI
+	dw		.ExitMenuByMenuLibrary	; .ExitMenu
+	dw		.NotHandled				; .IdleProcessing
+	dw		.NotHandled				; .ItemHighlightedFromCX
+	dw		.ItemSelectedFromCX		; .ItemSelectedFromCX
+	dw		.NotHandled				; .KeyStrokeInDX
+	dw		.RefreshTitle			; .RefreshTitle
+	dw		.RefreshInformation		; .RefreshInformation
+	dw		.RefreshItemFromCX		; .RefreshItemFromCX
 
 .rgszItems:
Index: trunk/Assembly_Library/Src/Menu/Dialog/Dialog.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/Dialog/Dialog.asm	(revision 55)
+++ trunk/Assembly_Library/Src/Menu/Dialog/Dialog.asm	(revision 58)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	6.8.2010
-; Last update	:	12.10.2010
+; Last update	:	18.11.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Common functions for many dialogs.
@@ -63,4 +63,5 @@
 ;--------------------------------------------------------------------
 ; Dialog_EventAnyThatClosesDialog
+; Dialog_EventExitMenu
 ;	Parameters:
 ;		SS:BP:	Ptr to DIALOG
@@ -73,4 +74,6 @@
 Dialog_EventAnyThatClosesDialog:
 	call	MenuInit_CloseMenuWindow
+ALIGN JUMP_ALIGN
+Dialog_EventExitMenu:
 	stc
 	ret
Index: trunk/Assembly_Library/Src/Menu/Dialog/DialogDrive.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/Dialog/DialogDrive.asm	(revision 55)
+++ trunk/Assembly_Library/Src/Menu/Dialog/DialogDrive.asm	(revision 58)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	22.10.2010
-; Last update	:	23.10.2010
+; Last update	:	18.11.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Displays drive dialog.
@@ -91,5 +91,5 @@
 istruc MENUEVENT
 	at	MENUEVENT.InitializeMenuinitFromDSSI,	dw	.InitializeMenuinitFromDSSI
-	at	MENUEVENT.ExitMenu,						dw	Dialog_EventNotHandled
+	at	MENUEVENT.ExitMenu,						dw	Dialog_EventExitMenu
 	at	MENUEVENT.IdleProcessing,				dw	Dialog_EventNotHandled
 	at	MENUEVENT.ItemHighlightedFromCX,		dw	Dialog_EventNotHandled
Index: trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm	(revision 55)
+++ trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm	(revision 58)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	6.9.2010
-; Last update	:	24.10.2010
+; Last update	:	18.11.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Displays file dialog.
@@ -101,5 +101,5 @@
 istruc MENUEVENT
 	at	MENUEVENT.InitializeMenuinitFromDSSI,	dw	InitializeMenuinitFromSSBP
-	at	MENUEVENT.ExitMenu,						dw	Dialog_EventNotHandled
+	at	MENUEVENT.ExitMenu,						dw	Dialog_EventExitMenu
 	at	MENUEVENT.IdleProcessing,				dw	Dialog_EventNotHandled
 	at	MENUEVENT.ItemHighlightedFromCX,		dw	Dialog_EventNotHandled
Index: trunk/Assembly_Library/Src/Menu/Dialog/DialogMessage.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/Dialog/DialogMessage.asm	(revision 55)
+++ trunk/Assembly_Library/Src/Menu/Dialog/DialogMessage.asm	(revision 58)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	6.8.2010
-; Last update	:	12.10.2010
+; Last update	:	18.11.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Displays message dialog.
@@ -59,5 +59,5 @@
 istruc MENUEVENT
 	at	MENUEVENT.InitializeMenuinitFromDSSI,	dw	.InitializeMenuinitFromDSSI
-	at	MENUEVENT.ExitMenu,						dw	Dialog_EventNotHandled
+	at	MENUEVENT.ExitMenu,						dw	Dialog_EventExitMenu
 	at	MENUEVENT.IdleProcessing,				dw	Dialog_EventNotHandled
 	at	MENUEVENT.ItemHighlightedFromCX,		dw	Dialog_EventNotHandled
Index: trunk/Assembly_Library/Src/Menu/Dialog/DialogProgress.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/Dialog/DialogProgress.asm	(revision 55)
+++ trunk/Assembly_Library/Src/Menu/Dialog/DialogProgress.asm	(revision 58)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	15.8.2010
-; Last update	:	12.10.2010
+; Last update	:	18.11.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Displays progress bar dialog and starts progress task.
@@ -120,5 +120,5 @@
 istruc MENUEVENT
 	at	MENUEVENT.InitializeMenuinitFromDSSI,	dw	.InitializeMenuinitFromDSSI
-	at	MENUEVENT.ExitMenu,						dw	Dialog_EventNotHandled
+	at	MENUEVENT.ExitMenu,						dw	Dialog_EventExitMenu
 	at	MENUEVENT.IdleProcessing,				dw	.IdleProcessing
 	at	MENUEVENT.ItemHighlightedFromCX,		dw	Dialog_EventNotHandled
Index: trunk/Assembly_Library/Src/Menu/Dialog/DialogSelection.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/Dialog/DialogSelection.asm	(revision 55)
+++ trunk/Assembly_Library/Src/Menu/Dialog/DialogSelection.asm	(revision 58)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	13.8.2010
-; Last update	:	12.10.2010
+; Last update	:	18.11.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Displays selection dialog.
@@ -51,5 +51,5 @@
 istruc MENUEVENT
 	at	MENUEVENT.InitializeMenuinitFromDSSI,	dw	.InitializeMenuinitFromDSSI
-	at	MENUEVENT.ExitMenu,						dw	Dialog_EventNotHandled
+	at	MENUEVENT.ExitMenu,						dw	Dialog_EventExitMenu
 	at	MENUEVENT.IdleProcessing,				dw	Dialog_EventNotHandled
 	at	MENUEVENT.ItemHighlightedFromCX,		dw	Dialog_EventNotHandled
Index: trunk/Assembly_Library/Src/Menu/Dialog/DialogString.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/Dialog/DialogString.asm	(revision 55)
+++ trunk/Assembly_Library/Src/Menu/Dialog/DialogString.asm	(revision 58)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	12.8.2010
-; Last update	:	12.10.2010
+; Last update	:	18.11.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Displays word input dialog.
@@ -62,5 +62,5 @@
 istruc MENUEVENT
 	at	MENUEVENT.InitializeMenuinitFromDSSI,	dw	.InitializeMenuinitFromDSSI
-	at	MENUEVENT.ExitMenu,						dw	Dialog_EventNotHandled
+	at	MENUEVENT.ExitMenu,						dw	Dialog_EventExitMenu
 	at	MENUEVENT.IdleProcessing,				dw	.IdleProcessing
 	at	MENUEVENT.ItemHighlightedFromCX,		dw	Dialog_EventNotHandled
Index: trunk/Assembly_Library/Src/Menu/Dialog/DialogWord.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/Dialog/DialogWord.asm	(revision 55)
+++ trunk/Assembly_Library/Src/Menu/Dialog/DialogWord.asm	(revision 58)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	10.8.2010
-; Last update	:	12.10.2010
+; Last update	:	18.11.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Displays word input dialog.
@@ -62,5 +62,5 @@
 istruc MENUEVENT
 	at	MENUEVENT.InitializeMenuinitFromDSSI,	dw	.InitializeMenuinitFromDSSI
-	at	MENUEVENT.ExitMenu,						dw	Dialog_EventNotHandled
+	at	MENUEVENT.ExitMenu,						dw	Dialog_EventExitMenu
 	at	MENUEVENT.IdleProcessing,				dw	.IdleProcessing
 	at	MENUEVENT.ItemHighlightedFromCX,		dw	Dialog_EventNotHandled
Index: trunk/Assembly_Library/Src/Menu/MenuEvent.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/MenuEvent.asm	(revision 55)
+++ trunk/Assembly_Library/Src/Menu/MenuEvent.asm	(revision 58)
@@ -34,6 +34,6 @@
 ;		SS:BP:	Ptr to MENU
 ;	Returns:
-;		CF:		Set if event processed
-;				Cleared if event not processed
+;		CF:		Set to exit from menu
+;				Cleared to cancel exit
 ;	Corrupts registers:
 ;		AX, BX, DX
Index: trunk/Assembly_Library/Src/Menu/MenuLoop.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/MenuLoop.asm	(revision 55)
+++ trunk/Assembly_Library/Src/Menu/MenuLoop.asm	(revision 58)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	22.7.2010
-; Last update	:	12.10.2010
+; Last update	:	18.10.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Menu loop for waiting keystrokes.
@@ -20,25 +20,16 @@
 ALIGN JUMP_ALIGN
 MenuLoop_Enter:
+	call	KeystrokeProcessing
+	call	TimeoutProcessing
+	call	IdleTimeProcessing
 	test	BYTE [bp+MENU.bFlags], FLG_MENU_EXIT
-	jnz		SHORT .ExitMenu
-	call	IdleTimeProcessing
-
-	call	MenuTime_UpdateSelectionTimeout
-	mov		ah, MENU_KEY_ENTER			; Fake ENTER to select item
-	jc		SHORT .ProcessFakedKeystrokeCausedByTimeout
-
-	call	Keyboard_GetKeystrokeToAX
 	jz		SHORT MenuLoop_Enter
-.ProcessFakedKeystrokeCausedByTimeout:
-	call	ProcessKeystrokeFromAX
-	jmp		SHORT MenuLoop_Enter
-
-ALIGN JUMP_ALIGN
-.ExitMenu:
-	jmp		MenuEvent_ExitMenu
+	ret
 
 
 ;--------------------------------------------------------------------
 ; IdleTimeProcessing
+; TimeoutProcessing
+; KeystrokeProcessing
 ;	Parameters
 ;		SS:BP:	Ptr to MENU
@@ -46,9 +37,22 @@
 ;		Nothing
 ;	Corrupts registers:
-;		AX, BX, DX
+;		All, except SS:BP
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 IdleTimeProcessing:
-	jmp		MenuEvent_IdleProcessing	; User idle processing
+	jmp		MenuEvent_IdleProcessing		; User idle processing
+
+ALIGN JUMP_ALIGN
+TimeoutProcessing:
+	call	MenuTime_UpdateSelectionTimeout
+	mov		ah, MENU_KEY_ENTER				; Fake ENTER to select item
+	jc		SHORT ProcessKeystrokeFromAX	; Process faked ENTER
+	ret
+
+ALIGN JUMP_ALIGN
+KeystrokeProcessing:
+	call	Keyboard_GetKeystrokeToAX
+	jnz		SHORT ProcessKeystrokeFromAX
+	ret
 
 
@@ -101,6 +105,9 @@
 ALIGN JUMP_ALIGN
 .LeaveMenuWithoutSelectingItem:
+	call	MenuEvent_ExitMenu
+	jnc		SHORT .CancelMenuExit
 	call	MenuInit_CloseMenuWindow
 	mov		WORD [bp+MENUINIT.wHighlightedItem], NO_ITEM_HIGHLIGHTED
+.CancelMenuExit:
 	stc
 	ret
