mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-14 14:19:08 +02:00
Cocoa: support keyboard in TCustomComboBox (TCocoaReadOnlyComboBox)
This commit is contained in:
parent
a914ea80b1
commit
db6685cd02
@ -319,7 +319,9 @@ type
|
|||||||
TCocoaReadOnlyComboBoxMenuDelegate = objcclass( NSObject, NSMenuDelegateProtocol )
|
TCocoaReadOnlyComboBoxMenuDelegate = objcclass( NSObject, NSMenuDelegateProtocol )
|
||||||
private
|
private
|
||||||
_lastHightlightItem: NSMenuItem;
|
_lastHightlightItem: NSMenuItem;
|
||||||
|
_comboBox: NSPopUpButton;
|
||||||
procedure menu_willHighlightItem (menu: NSMenu; item: NSMenuItem);
|
procedure menu_willHighlightItem (menu: NSMenu; item: NSMenuItem);
|
||||||
|
procedure menuDidClose (menu: NSMenu);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCocoaReadOnlyComboBox }
|
{ TCocoaReadOnlyComboBox }
|
||||||
@ -712,8 +714,6 @@ begin
|
|||||||
if Assigned(combobox) then
|
if Assigned(combobox) then
|
||||||
begin
|
begin
|
||||||
combobox.selectItemAtIndex(itemIndex);
|
combobox.selectItemAtIndex(itemIndex);
|
||||||
combobox.callback.ComboBoxSelectionDidChange;
|
|
||||||
combobox.menu.performActionForItemAtIndex(itemIndex);
|
|
||||||
combobox.menu.cancelTracking;
|
combobox.menu.cancelTracking;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1608,6 +1608,7 @@ begin
|
|||||||
Result:=inherited initWithFrame(frameRect);
|
Result:=inherited initWithFrame(frameRect);
|
||||||
_defaultItemHeight:= CocoaConfigComboBox.readOnly.item.defaultHeight;
|
_defaultItemHeight:= CocoaConfigComboBox.readOnly.item.defaultHeight;
|
||||||
_menuDelegate:= TCocoaReadOnlyComboBoxMenuDelegate.new;
|
_menuDelegate:= TCocoaReadOnlyComboBoxMenuDelegate.new;
|
||||||
|
_menuDelegate._comboBox:= self;
|
||||||
self.menu.setDelegate( _menuDelegate );
|
self.menu.setDelegate( _menuDelegate );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1867,6 +1868,11 @@ begin
|
|||||||
_lastHightlightItem:= item;
|
_lastHightlightItem:= item;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCocoaReadOnlyComboBoxMenuDelegate.menuDidClose(menu: NSMenu);
|
||||||
|
begin
|
||||||
|
TCocoaReadOnlyComboBox(_comboBox).comboboxAction( nil );
|
||||||
|
end;
|
||||||
|
|
||||||
{ TCocoaSpinEdit }
|
{ TCocoaSpinEdit }
|
||||||
|
|
||||||
{$IFDEF COCOA_SPINEDIT_INSIDE_CONTAINER}
|
{$IFDEF COCOA_SPINEDIT_INSIDE_CONTAINER}
|
||||||
|
@ -1977,8 +1977,6 @@ begin
|
|||||||
if not Assigned(rocmb) then Exit;
|
if not Assigned(rocmb) then Exit;
|
||||||
rocmb.isComboBoxEx:= AWinControl is TCustomComboBoxEx;
|
rocmb.isComboBoxEx:= AWinControl is TCustomComboBoxEx;
|
||||||
rocmb.list:=TCocoaReadOnlyComboBoxList.Create(rocmb);
|
rocmb.list:=TCocoaReadOnlyComboBoxList.Create(rocmb);
|
||||||
rocmb.setTarget(rocmb);
|
|
||||||
rocmb.setAction(objcselector('comboboxAction:'));
|
|
||||||
rocmb.lastSelectedItemIndex:= -1;
|
rocmb.lastSelectedItemIndex:= -1;
|
||||||
TComboBoxAsyncHelper.SetLastIndex(rocmb);
|
TComboBoxAsyncHelper.SetLastIndex(rocmb);
|
||||||
rocmb.callback:=TLCLComboboxCallback.Create(rocmb, AWinControl);
|
rocmb.callback:=TLCLComboboxCallback.Create(rocmb, AWinControl);
|
||||||
|
Loading…
Reference in New Issue
Block a user