mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 19:19:18 +02:00
IDE/Cocoa: add Ctrl+Command+F ShortCut for 'Search Instantly'
This commit is contained in:
parent
86a3eccf08
commit
be1b06eadc
@ -5,9 +5,9 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils,
|
Classes, SysUtils,
|
||||||
Forms,
|
Forms, Menus,
|
||||||
SourceEditor, SynEditTypes,
|
SourceEditor, SynEditTypes,
|
||||||
CocoaAll, CocoaConfig, CocoaToolBar, Cocoa_Extra, CocoaUtils;
|
CocoaAll, CocoaConfig, CocoaToolBar, Cocoa_Extra;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -16,6 +16,7 @@ type
|
|||||||
private
|
private
|
||||||
searchingString: String;
|
searchingString: String;
|
||||||
procedure doFindNext(Data: PtrInt);
|
procedure doFindNext(Data: PtrInt);
|
||||||
|
procedure doFocusSearchField( Sender: TObject );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -30,7 +31,23 @@ begin
|
|||||||
self.searchingString:= '';
|
self.searchingString:= '';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure searchHandle( const Sender: id );
|
procedure TCocoaIDEMainFormHandler.doFocusSearchField(Sender: TObject);
|
||||||
|
var
|
||||||
|
lclForm: TCustomForm;
|
||||||
|
cocoaItem: NSToolbarItem;
|
||||||
|
cocoaWindow: NSWindow;
|
||||||
|
begin
|
||||||
|
lclForm:= Screen.ActiveCustomForm;
|
||||||
|
cocoaItem:= TCocoaToolBarUtils.findItemByIdentifier( lclForm, 'MainIDE.Search' );
|
||||||
|
if NOT Assigned(cocoaItem) then
|
||||||
|
Exit;
|
||||||
|
cocoaWindow:= NSView(lclForm.Handle).window;
|
||||||
|
if NOT Assigned(cocoaWindow) then
|
||||||
|
Exit;
|
||||||
|
cocoaWindow.makeFirstResponder( TCocoaToolBarItemSearch(cocoaItem).searchField );
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure searchAction( const Sender: id );
|
||||||
var
|
var
|
||||||
searchField: NSSearchField absolute Sender;
|
searchField: NSSearchField absolute Sender;
|
||||||
begin
|
begin
|
||||||
@ -51,6 +68,24 @@ begin
|
|||||||
SourceEditorManager.JumpForwardClicked( nil );
|
SourceEditorManager.JumpForwardClicked( nil );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function onGetCommandMenu: TMenuItem;
|
||||||
|
var
|
||||||
|
menu: TMenuItem;
|
||||||
|
|
||||||
|
function createSearchMenuItem: TMenuItem;
|
||||||
|
begin
|
||||||
|
Result:= TMenuItem.Create( menu );
|
||||||
|
Result.Caption:= 'Search Instantly';
|
||||||
|
Result.OnClick:= @IDEMainFormHandler.doFocusSearchField;
|
||||||
|
Result.ShortCut:= ShortCut( Word('F'), [ssCtrl, ssMeta] );
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
menu:= TMenuItem.Create( nil );
|
||||||
|
menu.Add( createSearchMenuItem );
|
||||||
|
Result:= menu;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
const
|
const
|
||||||
backItemConfig: TCocoaConfigToolBarItem = (
|
backItemConfig: TCocoaConfigToolBarItem = (
|
||||||
@ -75,6 +110,19 @@ const
|
|||||||
onAction: @jumpForwardAction;
|
onAction: @jumpForwardAction;
|
||||||
);
|
);
|
||||||
|
|
||||||
|
commandItemConfig: TCocoaConfigToolBarItemMenu = (
|
||||||
|
identifier: 'MainIDE.Command';
|
||||||
|
iconName: 'ellipsis.circle';
|
||||||
|
title: 'Command';
|
||||||
|
tips: '';
|
||||||
|
bordered: True;
|
||||||
|
onAction: nil;
|
||||||
|
|
||||||
|
showsIndicator: False;
|
||||||
|
menu: nil;
|
||||||
|
onGetMenu: @onGetCommandMenu;
|
||||||
|
);
|
||||||
|
|
||||||
searchItemConfig: TCocoaConfigToolBarItemSearch = (
|
searchItemConfig: TCocoaConfigToolBarItemSearch = (
|
||||||
identifier: 'MainIDE.Search';
|
identifier: 'MainIDE.Search';
|
||||||
priority: NSToolbarItemVisibilityPriorityLow;
|
priority: NSToolbarItemVisibilityPriorityLow;
|
||||||
@ -82,7 +130,7 @@ const
|
|||||||
title: 'Search';
|
title: 'Search';
|
||||||
tips: 'Search Instantly';
|
tips: 'Search Instantly';
|
||||||
bordered: True;
|
bordered: True;
|
||||||
onAction: @searchHandle;
|
onAction: @searchAction;
|
||||||
|
|
||||||
sendWhole: False;
|
sendWhole: False;
|
||||||
sendImmediately: False;
|
sendImmediately: False;
|
||||||
@ -115,12 +163,14 @@ const
|
|||||||
defaultItemsIdentifiers: (
|
defaultItemsIdentifiers: (
|
||||||
'MainIDE.Back',
|
'MainIDE.Back',
|
||||||
'MainIDE.Forward',
|
'MainIDE.Forward',
|
||||||
'MainIDE.Search'
|
'MainIDE.Search',
|
||||||
|
'MainIDE.Command'
|
||||||
);
|
);
|
||||||
allowedItemsIdentifiers: (
|
allowedItemsIdentifiers: (
|
||||||
'MainIDE.Back',
|
'MainIDE.Back',
|
||||||
'MainIDE.Forward',
|
'MainIDE.Forward',
|
||||||
'MainIDE.Search'
|
'MainIDE.Search',
|
||||||
|
'MainIDE.Command'
|
||||||
);
|
);
|
||||||
itemCreator: nil; // default item Creator
|
itemCreator: nil; // default item Creator
|
||||||
);
|
);
|
||||||
@ -131,6 +181,7 @@ begin
|
|||||||
mainIDEFormConfig.toolBar.items:= [
|
mainIDEFormConfig.toolBar.items:= [
|
||||||
TCocoaToolBarUtils.toClass(backItemConfig),
|
TCocoaToolBarUtils.toClass(backItemConfig),
|
||||||
TCocoaToolBarUtils.toClass(forwardItemConfig),
|
TCocoaToolBarUtils.toClass(forwardItemConfig),
|
||||||
|
TCocoaToolBarUtils.toClass(commandItemConfig),
|
||||||
TCocoaToolBarUtils.toClass(searchItemConfig)
|
TCocoaToolBarUtils.toClass(searchItemConfig)
|
||||||
];
|
];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user