[futurebasic] Re: [FB] Carbon Toolbar window question

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 2010 : Group Archive : Group : All Groups

From: Bernie <fblist.bw@...>
Date: Tue, 23 Nov 2010 13:06:13 +0000
Steve wrote:

> I am trying  place a search field in a toolbar using the Carbon Toolbar examples but have been unsuccessful.  
> Any advice would be appreciated.

'---------------
include "Util_Toolbar.incl"

local fn MyCreateSearchField as HIViewRef
'~'1
dim as HIViewRef   view : view = 0

fn HISearchFieldCreate( #0, _kHISearchFieldNoAttributes, 0, 0, @view )
fn HISearchFieldSetDescriptiveText( view, @"Enter search string" )

// install search field event handlers here

end fn = view

local fn BuildToolbar
'~'1
dim as CFStringRef   identifier

// the toolbar
fn ToolbarCreate( 0, @"com.mycompany.mywonderfulapp.carbontoolbar", _kHIToolbarNoAttributes )

// the items
fn ToolbarItemSetDefault( 0, kHIToolbarFlexibleSpaceIdentifier )

identifier = @"SearchField"
fn ToolbarItem( 0, identifier, 0, 0, 0, 0, _true )
fn ToolbarCustomItem( 0, identifier, @"com.MySearchFieldClass", @fn MyCreateSearchField, 0.0, 20.0, 200.0, 20.0 )

// display mode
fn ToolbarSetDisplayMode( 0, _kHIToolbarDisplayModeIconOnly )
end fn

fn BuildToolbar()
appearance window 1, "Toolbar Search Field", (0,0)-(540,360), _kDocumentWindowClass, _kWindowStandardDocumentAttributes _kWindowToolbarButtonAttribute _kWindowLiveResizeAttribute _kWindowCompositingAttribute
fn ToolbarAttachToWindow( 0, window( _wndRef ), _true )

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

Bernie