[futurebasic] Re: [FB] Contextual Menu

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : September 2004 : Group Archive : Group : All Groups

From: Brian Heibert <bheibert@...>
Date: Thu, 23 Sep 2004 19:32:40 -0500
Hi,

I tried that and got:
Error:  End of Statement expected here...
After compiling this statement, I encountered extra (Unexpected)
information.
Example: Too many parameters or missing operation(s).
in file TBASIC.proj:TBASIC.MAIN at line 374 in PopControlClickedMenu
€dim @ menuID         €as short

Error: Unknown Statement: 'as '
in file TBASIC.proj:TBASIC.MAIN at line 374 in PopControlClickedMenu
dim @ menuID         €as €short

Error:  End of Statement expected here...
After compiling this statement, I encountered extra (Unexpected)
information.
Example: Too many parameters or missing operation(s).
in file TBASIC.proj:TBASIC.MAIN at line 379 in PopControlClickedMenu
€dim err              €as OSStatus

Error: Unknown Statement: 'as '
in file TBASIC.proj:TBASIC.MAIN at line 379 in PopControlClickedMenu
dim err              €as €OSStatus

Error: Array Variable 'INSERTMENU' not an array or undimensioned
in file TBASIC.proj:TBASIC.MAIN at line 387 in PopControlClickedMenu
  €InsertMenu(€mHndl, -1)

Error: Unknown Statement: 'InsertMenu('
in file TBASIC.proj:TBASIC.MAIN at line 387 in PopControlClickedMenu
  €InsertMenu(€mHndl, -1)

Error: Array Variable 'APPENDMENU' not an array or undimensioned
in file TBASIC.proj:TBASIC.MAIN at line 390 in PopControlClickedMenu
€AppendMenu(€mHndl, "Item 1")

Error: Unknown Statement: 'AppendMenu('
in file TBASIC.proj:TBASIC.MAIN at line 390 in PopControlClickedMenu
€AppendMenu(€mHndl, "Item 1")

Error: Array variable missing end Œ)¹.
in file TBASIC.proj:TBASIC.MAIN at line 391 in PopControlClickedMenu
€AppendMenu(mHndl€, "Item 2")

Error: Unknown Statement: 'AppendMenu(mHndl'
in file TBASIC.proj:TBASIC.MAIN at line 391 in PopControlClickedMenu
€AppendMenu(mHndl€, "Item 2")


On 9/22/04 11:26 PM, "Robert Covington" <artlythere@...> wrote:

> 
> On Wednesday, September 22, 2004, at 10:57  PM, Brian Heibert wrote:
> 
>> I have a menu resource that I want to use as a contextual menu in my
>> program.  My program has a window with a edit field that fills up the
>> window.
>> 
>> Are there any examples out there on how to do this?
>> 
>> Brian
> 
> Not sure how to use a menu resource (tired right now, and fading), but
> here's an example of a manually built one...control click to bring up
> the menu.
> 
> 
> // NETE Macro App Shell
> // Robert Covington
> 
> 
> Begin Globals
> dim gQuit as int
> End Globals
> 
> Begin Enum 1
> _wWindow1
> end Enum
> 
> Begin Enum 1
> _mFile
> _mEdit
> _mOther
> end Enum
> 
> Begin Enum
> _mFileTitleItem
> _mfileOpenItem
> _mfileCloseItem
> _mfileNullItem
> _mfileQuitItem
> end Enum
> 
> 
> _PopClickMenu          = 150
> _kCMHelpItemRemoveHelp = 3
> 
> // Bernie aided me with this here widget
> '~';
> clear local
> dim enableRemove
> local fn PopControlClickedMenu(wnd as long , pt as point)
> dim @ selectionType  as long
> DIm as long    @lNumber         , dirID
> dim @ menuID         as short
> DIM @fontNum         as short
> dim @ menuItem       as short
> dim @ r              as rect
> dim mHndl            as Handle
> dim err              as OSStatus
> dim helpItemString   as Str255
> dim where            as Point
> DIM OSErr            as OSErr
> dim                  as int insert,i
> '~'1
> 
> mHndl = fn NewMenu(_PopClickMenu, "")
> InsertMenu(mHndl, -1)
> helpItemString = ""
> 
> AppendMenu(mHndl, "Item 1")
> AppendMenu(mHndl, "Item 2")
> AppendMenu(mHndl, "Item 3")
> 
> '~';
> // could set to always pop in the same place here
> where.h% = pt.h%
> where.v% = pt.v%
> localtoGlobal(where)
> '~';
> long if mHndl
> err   = fn ContextualMenuSelect(mHndl, #where , _nil,
> _kCMHelpItemRemoveHelp, @helpItemString, #_nil, @selectionType,
> @menuID, @menuItem)
> 
> select menuID
> case _PopClickmenu
> select menuItem
> case 1
> 
> case 2
> beep
> case 3
> 
> end select
> 
> end select
> 
> end if
> 
> 
> deleteMenu(_PopClickMenu)
> 
> 
> end fn
> 
> 
> 
> local fn BuildWindow
> dim as Str255              s
> dim as ControlFontStyleRec cfs
> dim as WindowAttributes    wa
> dim as Rect                r
> '~'1
> cfs.flags = _kControlUseFontMask_kControlUseJustMask
> wa = _kWindowCloseBoxAttribute¬
>     _kWindowCollapseBoxAttribute¬
>     _kWindowFullZoomAttribute¬
>     _kWindowResizableAttribute
> 
> 
> SetRect(r, 0, 0, 400 , 400)
> appearance window -_wWindow1,¬
>                  "Test Window", @r,¬
>                  _kDocumentWindowClass, wa
> def SetWindowBackground(_kThemeActiveDialogBackgroundBrush, _zTrue)
> '~'1
> 
> appearance window _wWindow1
> 
> end fn
> 
> 
> Local FN OpenSomeFile
> dim fName$
> dim oSpec as FSSpec
> 
> fName$ = Files$(_FSSpecOpenPreview,"TEXTPICT","Choose a file...", oSpec
> )
> long if len(fName$)
> // Good File return
> Open "I",#1,@oSpec
> // Read it
> close #1
> end if
> 
> end fn
> 
> local fn DoDialog
> dim as long evnt, id
> dim as point pt
> '~'1
> evnt = dialog(0)
> id = dialog(evnt)
> select evnt
> case _cntxtMenuClick
> GetMouse(pt)
> fn PopControlClickedMenu(id, pt )
> case _wndClick
> window id
> case _wndClose
> window close id
> case _wndRefresh
> case _wndResized
> case _wndActivate
> case _btnClick
> case _preview
> select id
> case _preMenuClick
> case _preWndGrow
> end select
> end select
> end fn
> 
> Local FN DoMouse
> Dim mFunc
> mFunc = Mouse(0)
> select mFunc
> case _click1NDrag
> case else
> beep
> end Select
> end fn
> 
> 
> 
> Local Fn DoMenu
> Dim as int menuID,itemID
> menuID = Menu(_menuID)
> itemID = Menu(_itemID)
> Select menuID
> Case _mFile
> Select itemID
> Case _mFileOpenItem
> FN OpenSomeFile
> Case _mFileCloseItem
> Window Close _wWindow1
> case _mFileQuitItem
> gQuit = _True
> End Select
> Case _mEdit
> Select itemID
> Case 1
> Case 2
> case 3
> End Select
> Case _mOther
> Select itemID
> Case 1
> Case 2
> case 3
> End Select
> End Select
> Menu
> End fn
> 
> 
> Local Fn Init_Menus
> 
> Menu _mFile, _mFileTitleItem , _Enable , "File"
> Menu _mFile, _mfileOpenItem  , _Enable , "Open.../O"
> Menu _mFile, _mfileCloseItem , _Enable , "Close/W"
> Menu _mFile, _mfileNullItem  , _Enable , "-"
> Menu _mFile, _mfileQuitItem  , _Enable , "Quit/Q"
> 
> End fn
> 
> '~';
> "MAIN"
> '~';
> 
> Fn Init_Menus
> fn BuildWindow
> 
> on Dialog Fn DoDialog
> On Menu   Fn DoMenu
> on Mouse  Fn DoMouse
> 
> do
> HandleEvents
> until gQuit
> 
> --
>