FUNCTIONS GT

GTI_CLOSEMODE

Query or change what the close button does

Syntax

Signature
GtInfo( GTI_CLOSEMODE, [nMode] ) --> nMode

Arguments

GTI_CLOSEMODE

The selector, from gtinfo.ch.

nMode

0, 1 or 2.

Return value

The mode before the call.

Description

The modes:

nModeThe close button
0ends the program
1sends K_CLOSE to Inkey()
2is disabled

With mode 1 the program can ask whether to save its data before it ends.

Notes

Supported by GTWVT, GTSDL3, GTXWC and GTGLFW. On other terminals the result is NIL.

Compare event and disabled modes without letting the close button terminate the sample.

Example

GTI_CLOSEMODE.prg
#include "inkey.ch"
#include "gtinfo.ch"

#if OS_LINUX
   REQUEST GTXWC
#else
   REQUEST GTWVT
#endif

PROCEDURE Main()

   LOCAL nSaved := GtInfo( GTI_CLOSEMODE )
   LOCAL nMode := 1
   LOCAL nRequests := 0
   LOCAL nKey

   IF ValType( nSaved ) != "N"
      OutStd( "Close-button modes unavailable.", Eol() )
      RETURN
   ENDIF

   DO WHILE .T.
      GtInfo( GTI_CLOSEMODE, nMode )
      Scroll()
      DispOutAt( 1, 2, IIF( nMode == 1, "Close button sends K_CLOSE", "Close button disabled" ) )
      DispOutAt( 2, 2, "Close requests received: " + LTrim( Str( nRequests ) ) )
      DispOutAt( 4, 2, "Try the close button. Space switches modes. Esc exits." )
      nKey := Inkey( 12, INKEY_KEYBOARD + INKEY_GTEVENT )
      DO CASE
      CASE nKey == 0 .OR. nKey == K_ESC
         EXIT
      CASE nKey == K_SPACE
         nMode := 3 - nMode
      CASE nKey == K_CLOSE
         nRequests++
      ENDCASE
   ENDDO

   GtInfo( GTI_CLOSEMODE, nSaved )

RETURN

Output

See also