[futurebasic] Re: [FB] too many arguments

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : July 2011 : Group Archive : Group : All Groups

From: Bernie <fblist.bw@...>
Date: Tue, 26 Jul 2011 12:49:00 +0100
Steve wrote:

> I am getting an error when trying to use this call.  It states it expects 6 arguments but there are 7.
> 
> Error: clang:
> too many arguments to function call, expected 6, have 7 [line 377:59 of _27_eventhandler.incl,palette.incl.m]
> 
> toolbox fn RegisterEventHotKey( UInt32 inHotKeyCode, UInt32 inHotKeyModifiers, OSType signature, UInt32 id, EventTargetRef inTarget, UInt32 inOptions, EventHotKeyRef *outRef ) = OSStatus
> 

That toolbox declaration in Tlbx CarbonEvents.incl is wrong for FB5.

[1] Cmd-double-click it to highlight it and change to:
'---------------
toolbox fn RegisterEventHotKey( UInt32 inHotKeyCode, UInt32 inHotKeyModifiers, EventHotKeyID inHotKeyID, EventTargetRef inTarget, OptionBits inOptions, EventHotKeyRef *outRef ) = OSStatus
'---------------

[2] Now change your RegisterHotKeys function to:
'---------------
local mode
local fn RegisterHotKeys
'~'1
dim as EventTargetRef   target
dim as EventHotKeyRef   hotKeyref
dim as EventHotKeyID    hotKeyID

target = fn GetApplicationEventTarget()

hotKeyID.signature = 0
hotKeyID.id = 2

// the magic hex numbers here are the relevant virtual key codes
fn RegisterEventHotKey( 0x78, 0, hotKeyID, target, 0, @hotKeyref ) // F2
fn SetMenuItemProperty( fn GetMenuHandle( _mEdit ), _iCut, 0, _hotProperty, sizeof( EventHotKeyRef ), @hotKeyref )

hotKeyID.id = 3
fn RegisterEventHotKey( 0x63, 0, hotKeyID, target, 0, @hotKeyref ) // F3
fn SetMenuItemProperty( fn GetMenuHandle( _mEdit ), _iCopy, 0, _hotProperty, sizeof( EventHotKeyRef ), @hotKeyref )

hotKeyID.id = 4
fn RegisterEventHotKey( 0x76, 0, hotKeyID, target, 0, @hotKeyref ) // F4
fn SetMenuItemProperty( fn GetMenuHandle( _mEdit ), _iPaste, 0, _hotProperty, sizeof( EventHotKeyRef ), @hotKeyref )
end fn
'---------------

Bernie