[futurebasic] [FB] Check/Unchecking Menu Item

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 1999 : Group Archive : Group : All Groups

From: Ken Shmidheiser <kshmidheiser@...>
Date: Mon, 17 May 1999 09:49:40 -0400
Tedd wrote:

>Ken:
>
>Two things I do: 1) Create a global gSoundFlag; 2) Then turn it on/off
>(_true/_false) via the menu. From there, through-out your program you can
>use it like so:


Tedd,

I took your suggestion and this is how I have implemented the menu toggling
this morning after I received your post. I just wanted to check with you
and the group to be sure I have it right. (Seems to work fine, but I'd
rather do it right now than try to fix it later on in development.)

I'll work on George's idea tonight if I have time after work (long day
today!) Then my only problem will be trying to figure which is best!

Thanks again so much Tedd and George, and for the group bearing with me.

Ken

p.s. I welcome any and all suggestions on optimizing my code.


'---------------- Constants ----------------

_mAppleMenu = 255

_mFileMenu = 1
_mMapMenu = 1
_mSound = 2
_iQuit = 4

_testWindow = 1
_aboutWindow = 2
_mapWindow = 3


'---------------- Globals -------------------

DIM gSoundFlag
END GLOBALS

'---------------- Functions -----------------

LOCAL FN testWindow
  COORDINATE WINDOW

  TEXT _geneva, 12

  WINDOW _testWindow, "Menu Test Window", (0,0)-(280,100),_docNoGrow

  MENU 1,0, _enable, "File"                       'Menu items defined
  MENU 1,1, _enable, "Show map"
  MENU 1,2, _enable, "Sound on"                   'Sound menu initially enabled
  MENU 1,3, _enable, "-"
  MENU 1,4, _enable, "/QQuit"

  APPLE MENU "About this program..."

  EDIT FIELD 1, "Text for Main window test only.",
(10,40)-(270,60),_statNoFramed,_centerJust

  EDIT FIELD #0

END FN

LOCAL FN aboutWindow
  COORDINATE WINDOW

  TEXT _geneva, 12

  WINDOW _aboutWindow, "About Menu Test Window", (5,40)-(280,130),_docNoGrow

  EDIT FIELD 2, "Text for About Window Menu test.",
(10,40)-(270,60),_statNoFramed, _centerJust
  EDIT FIELD #0

END FN

LOCAL FN mapWindow
  COORDINATE WINDOW

  TEXT _geneva, 12

  WINDOW _mapWindow, "Map Menu Test Window", (5,160)-(280,250),_docNoGrow

  EDIT FIELD 2, "Text for Map Window Menu test.",
(10,40)-(270,60),_statNoFramed, _centerJust
  EDIT FIELD #0

END FN


LOCAL FN playSound
  gSoundFlag = _true
  BEEP : BEEP : BEEP
END FN


LOCAL FN noSound
  gSoundFlag = _false
  BEEP
END FN


LOCAL FN doDialog
  evnt = DIALOG(0)
  id   = DIALOG(evnt)

  SELECT evnt

    CASE _wndClick
      SELECT id
        CASE _testWindow
          WINDOW _testWindow
        CASE _mapWindow
          WINDOW _mapWindow
        CASE _aboutWindow
      END SELECT

    CASE _wndClose
      SELECT id
        CASE _testWindow
          WINDOW CLOSE _testWindow
        CASE _mapWindow
          WINDOW CLOSE _mapWindow
        CASE _aboutWindow
          WINDOW CLOSE _aboutWindow
      END SELECT

  END SELECT

END FN


LOCAL FN doMenu
  menuID = MENU(_menuID)
  itemID = MENU(_itemID)

  SELECT menuID
    CASE _mFileMenu
      SELECT itemID
        CASE _mMapMenu
          WINDOW CLOSE _mapWindow
          FN mapWindow
          MENU
        CASE _mSound
          SELECT
            CASE gSoundFlag = _false
              MENU 1,2, _checked,"Sound On"
              FN playSound
              MENU
            CASE gSoundFlag = _true
              MENU 1,2, _enable,"Sound Off"
              FN noSound
              MENU
          END SELECT

        CASE _iQuit
          END
      END SELECT

    CASE _mAppleMenu
      WINDOW CLOSE _aboutWindow
      FN aboutWindow

  END SELECT

END FN

'---------------- Event Loop -----------------
WINDOW OFF

ON DIALOG FN doDialog
ON MENU FN doMenu

FN testWindow

DO
  HANDLEEVENTS
UNTIL 0

___________________________________________________________________
Ken Shmidheiser               Systems Administrator/General Manager

Internet: kshmidheiser@...    Fax:  606.679.9225
Somerset, KY 42502-0221                        Phone:  606.679.4266
___________________________________________________________________