[futurebasic] Check/Unchecking Menu Item

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

From: Ken Shmidheiser <kshmidheiser@...>
Date: Sun, 16 May 1999 06:04:16 -0400
I'm stumped over how to toggle a menu between _enable and _checked and
back. In this demo, by selecting the "Play program sounds" menu item, it
becomes checked and then calls a function. But I can't figure out how to
get rid of the check mark and reset the menu to _enable. In my program, I
would like the user to be able to toggle the sound on and off. I have tried
rebuilding the menu in FN playSound and in seperate functions without
success. Also, I can't figure out a CASE/SELECT structure to do in FN
doMenu to allow toggling. I have tried without success to implement:

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

  SELECT menuID
    CASE _mFileMenu
      SELECT itemID
        CASE _mSound
          SELECT                  '<----  I know this is funky from here...
            CASE _enable
             MENU
             MENU 1,2, _checked, "Play program sounds"
             FN playSound
             MENU
           SELECT
            CASE _checked
              MENU 1,2, _enable
             FN turnSoundOffReset '<----  ...to here, but I'm desperate!
        CASE _iQuit
          END
      END SELECT
    CASE _mAppleMenu
      WINDOW CLOSE _aboutWindow
      FN aboutWindow
  END SELECT
END FN


I figure I might be getting into some toolbox routines (CALL DELETEMENU,
CALL INSERTMENU, CALL SETITEMMARK, etc.) but I'm clueless about how to use
them.

Any and all tips, criticism, advice, etc. is gladly welcome.


'Stand-alone demo (please adjust e-mail line breaks)

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

_mAppleMenu = 255

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

_testWindow = 1
_aboutWindow = 2
_mapWindow = 3

'---------------- 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, "Play program sounds"        '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
  BEEP : 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
          MENU
          MENU 1,2, _checked, "Play program sounds"'<--- Here's the problem
          FN playSound
          MENU
                 '<--- I can't figure out what I need to add reset the menu

        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
___________________________________________________________________