[futurebasic] Mouse Tracking on CE Handler

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

From: Yoshiyuki Hasegawa <hase44@...>
Date: Tue, 18 Sep 2007 01:13:40 +0900
Hi all,

How is the cursor changed into I-Beam when the mouse comes on Edit  
Field on CE Handler?

Yoshiyuki

Sample code.
'------------------------------
include "Tlbx CarbonEvents.incl"

begin enum 1
_Untitled1Wnd
end enum

begin enum 1
_cEdit
_c1Edit
_c2Edit
end enum

#define FMFontFamily as SInt16
toolbox fn FMGetFontFamilyFromName(Str255 iName) = FMFontFamily

long if 0
"WindowEventHandler"
enterproc fn WindowEventHandler( nextHandler as EventHandlerCallRef,  
theEvent as EventRef, wNum as long ) = OSStatus
'~'1
dim as WindowRef    @ w
dim as OSStatus     result, ignore
dim as MouseTrackingRef  @ mtrRef

result = _eventNotHandledErr
//ignore = fn GetEventParameter( theEvent, _kEventParamDirectObject,  
_typeWindowRef, #0, sizeof( WindowRef ), #0, @w )

ignore = fn GetEventParameter( theEvent,  
_kEventParamMouseTrackingRef, _typeMouseTrackingRef, #0, sizeof 
( MouseTrackingRef ), #0, @mtrRef )

select fn GetEventClass( theEvent )
case _kEventClassWindow
select fn GetEventKind( theEvent )
case _kEventWindowActivated
window wNum
result = _noErr
case _kEventWindowClose
select ( wNum )
case _Untitled1Wnd
end
result = _noErr
end select
end select

case _kEventClassMouse
select fn GetEventKind( theEvent )
case _kEventMouseEntered
beep
ignore = fn SetThemeCursor( _kThemeIBeamCursor )
result = _noErr

case _kEventMouseExited
beep
ignore = fn SetThemeCursor( _kThemeArrowCursor )
result = _noErr

end select

end select

exitproc = result
end if

local fn InstallWindowHandler( wNum as long )
'~'1
dim as WindowRef @ w

_nWindEventKinds = 4
dim as EventTypeSpec  events(_nWindEventKinds - 1)
begin globals
dim as proc  sWindowEventUPP
end globals

long if ( sWindowEventUPP == _nil )

#if def _FBtoC
sWindowEventUPP = fn NewEventHandlerUPP( Proc "WindowEventHandler" )
#else
sWindowEventUPP = fn NewEventHandlerUPP( [Proc "WindowEventHandler" +  
_FBprocToProcPtrOffset] )
#endif

end if

events.eventClass(0) = _kEventClassWindow
events.eventKind(0)  = _kEventWindowActivated

events.eventClass(1) = _kEventClassWindow
events.eventKind(1)  = _kEventWindowClose

events.eventClass(2) = _kEventClassMouse
events.eventKind(2)  = _kEventMouseEntered

events.eventClass(3) = _kEventClassMouse
events.eventKind(3)  = _kEventMouseExited

get window wNum, w

end fn = fn InstallEventHandler( fn GetWindowEventTarget( w ),  
sWindowEventUPP, _nWindEventKinds, @events(0), #wNum, #0 )

local fn BuildUntitled1Wnd
dim as Str255            s
dim as ControlFontStyleRec tfs
dim as WindowAttributes    wa
dim as Rect              r
'~'<
wa = _kWindowCloseBoxAttribute _kWindowStandardHandlerAttribute

def NewWindowPositionMethod(_kWindowCenterOnMainScreen)
SetRect(r, 466, 384, 766, 684)// w: 300 h: 300
appearance window -_Untitled1Wnd, "Untitled 1", @r,  
_kDocumentWindowClass, wa
def NewWindowPositionMethod(0)
def SetWindowBackground(_kThemeActiveDialogBackgroundBrush, _zTrue)
'~'<
tfs.flags =  
_kControlUseFontMask_kControlUseSizeMask_kControlUseFaceMask_kControlUse 
JustMask
tfs.font  = fn FMGetFontFamilyFromName("Lucida Grande")
tfs.size  = 13
tfs.style = 0
tfs.just  = _teJustLeft

SetRect(r, 23, 40, 277, 56)
appearance button _cEdit, _activeBtn,,,,, @r,  
_kControlEditUnicodeTextProc
def SetButtonFontStyle(_cEdit, tfs)
s = "Edit Text"
def SetButtonTextString(_cEdit, s)

OffSetRect(r, 0, 60)
appearance button _c1Edit, _activeBtn,,,,, @r,  
_kControlEditUnicodeTextProc
def SetButtonFontStyle(_c1Edit, tfs)
s = "Edit Text"
def SetButtonTextString(_c1Edit, s)

OffSetRect(r, 0, 60)
appearance button _c2Edit, _activeBtn,,,,, @r,  
_kControlEditUnicodeTextProc
def SetButtonFontStyle(_c2Edit, tfs)
s = "Edit Text"
def SetButtonTextString(_c2Edit, s)

fn InstallWindowHandler( _Untitled1Wnd )

appearance window _Untitled1Wnd
end fn

fn BuildUntitled1Wnd

RunApplicationEventLoop()
'----------------------------------------