mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-01 15:00:24 +02:00
Cocoa: Fixes bug #30847: TComboBox with ReadOnly=True cant show repeated items
git-svn-id: trunk@54947 -
This commit is contained in:
parent
5eb469913c
commit
ff26552571
@ -514,16 +514,20 @@ type
|
|||||||
function acceptsFirstResponder: Boolean; override;
|
function acceptsFirstResponder: Boolean; override;
|
||||||
function becomeFirstResponder: Boolean; override;
|
function becomeFirstResponder: Boolean; override;
|
||||||
function resignFirstResponder: Boolean; override;
|
function resignFirstResponder: Boolean; override;
|
||||||
|
// NSComboBoxDataSourceProtocol
|
||||||
function comboBox_objectValueForItemAtIndex_(combo: TCocoaComboBox; row: NSInteger): id; message 'comboBox:objectValueForItemAtIndex:';
|
function comboBox_objectValueForItemAtIndex_(combo: TCocoaComboBox; row: NSInteger): id; message 'comboBox:objectValueForItemAtIndex:';
|
||||||
function numberOfItemsInComboBox(combo: TCocoaComboBox): NSInteger; message 'numberOfItemsInComboBox:';
|
function numberOfItemsInComboBox(combo: TCocoaComboBox): NSInteger; message 'numberOfItemsInComboBox:';
|
||||||
|
//
|
||||||
procedure dealloc; override;
|
procedure dealloc; override;
|
||||||
function lclGetCallback: ICommonCallback; override;
|
function lclGetCallback: ICommonCallback; override;
|
||||||
procedure lclClearCallback; override;
|
procedure lclClearCallback; override;
|
||||||
procedure resetCursorRects; override;
|
procedure resetCursorRects; override;
|
||||||
|
// NSComboBoxDelegateProtocol
|
||||||
procedure comboBoxWillPopUp(notification: NSNotification); message 'comboBoxWillPopUp:';
|
procedure comboBoxWillPopUp(notification: NSNotification); message 'comboBoxWillPopUp:';
|
||||||
procedure comboBoxWillDismiss(notification: NSNotification); message 'comboBoxWillDismiss:';
|
procedure comboBoxWillDismiss(notification: NSNotification); message 'comboBoxWillDismiss:';
|
||||||
procedure comboBoxSelectionDidChange(notification: NSNotification); message 'comboBoxSelectionDidChange:';
|
procedure comboBoxSelectionDidChange(notification: NSNotification); message 'comboBoxSelectionDidChange:';
|
||||||
procedure comboBoxSelectionIsChanging(notification: NSNotification); message 'comboBoxSelectionIsChanging:';
|
procedure comboBoxSelectionIsChanging(notification: NSNotification); message 'comboBoxSelectionIsChanging:';
|
||||||
|
//
|
||||||
function lclIsHandle: Boolean; override;
|
function lclIsHandle: Boolean; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -3438,7 +3442,7 @@ procedure TCocoaComboBoxList.Changed;
|
|||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
nsstr: NSString;
|
nsstr: NSString;
|
||||||
lCurItem: NSMenuItem;
|
lItems: array of NSMenuItem;
|
||||||
begin
|
begin
|
||||||
if FOwner <> nil then
|
if FOwner <> nil then
|
||||||
fOwner.reloadData;
|
fOwner.reloadData;
|
||||||
@ -3448,12 +3452,24 @@ begin
|
|||||||
FReadOnlyOwner.lastSelectedItemIndex := FReadOnlyOwner.indexOfSelectedItem;
|
FReadOnlyOwner.lastSelectedItemIndex := FReadOnlyOwner.indexOfSelectedItem;
|
||||||
|
|
||||||
FReadOnlyOwner.removeAllItems();
|
FReadOnlyOwner.removeAllItems();
|
||||||
|
// Adding an item with its final name will cause it to be deleted,
|
||||||
|
// so we need to first add all items with unique names, and then
|
||||||
|
// rename all of them, see bug 30847
|
||||||
|
SetLength(lItems, Count);
|
||||||
|
for i := 0 to Count-1 do
|
||||||
|
begin
|
||||||
|
nsstr := NSStringUtf8(Format('unique_item_%d', [i]));
|
||||||
|
FReadOnlyOwner.addItemWithTitle(nsstr);
|
||||||
|
lItems[i] := FReadOnlyOwner.lastItem;
|
||||||
|
nsstr.release;
|
||||||
|
end;
|
||||||
for i := 0 to Count-1 do
|
for i := 0 to Count-1 do
|
||||||
begin
|
begin
|
||||||
nsstr := NSStringUtf8(Strings[i]);
|
nsstr := NSStringUtf8(Strings[i]);
|
||||||
FReadOnlyOwner.addItemWithTitle(nsstr);
|
lItems[i].setTitle(nsstr);
|
||||||
nsstr.release;
|
nsstr.release;
|
||||||
end;
|
end;
|
||||||
|
SetLength(lItems, 0);
|
||||||
|
|
||||||
// reset the selected item
|
// reset the selected item
|
||||||
FReadOnlyOwner.selectItemAtIndex(FReadOnlyOwner.lastSelectedItemIndex);
|
FReadOnlyOwner.selectItemAtIndex(FReadOnlyOwner.lastSelectedItemIndex);
|
||||||
|
Loading…
Reference in New Issue
Block a user