cocoa: patch by Davin Jenkins #32828. partially applied - textDidChange() and custom item draw for CocoaListBox

git-svn-id: trunk@56755 -
This commit is contained in:
dmitry 2017-12-16 03:48:05 +00:00
parent b261873d98
commit 84920379fa

View File

@ -250,6 +250,7 @@ type
// key
//procedure keyDown(event: NSEvent); override; -> keyDown doesn't work in NSTextField
procedure keyUp(event: NSEvent); override;
procedure textDidChange(notification: NSNotification); override;
end;
{ TCocoaSecureTextField }
@ -611,6 +612,8 @@ type
procedure tableViewSelectionDidChange(notification: NSNotification); message 'tableViewSelectionDidChange:';
procedure drawRow_clipRect(row: NSInteger; clipRect: NSRect); override;
procedure dealloc; override;
procedure resetCursorRects; override;
@ -1963,6 +1966,12 @@ begin
inherited keyUp(event);
end;
procedure TCocoaTextField.textDidChange(notification: NSNotification);
begin
if callback <> nil then
callback.SendOnTextChanged;
end;
{ TCocoaTextView }
function TCocoaTextView.lclIsHandle: Boolean;
@ -2820,6 +2829,29 @@ begin
end;
end;
procedure TCocoaListBox.drawRow_clipRect(row: NSInteger; clipRect: NSRect);
var
DrawStruct: TDrawListItemStruct;
ctx: TCocoaContext;
LCLObject: TCustomListBox;
begin
inherited;
ctx := TCocoaContext.Create(NSGraphicsContext.currentContext);
DrawStruct.Area := NSRectToRect(rectOfRow(row));
DrawStruct.DC := HDC(ctx);
DrawStruct.ItemID := row;
LCLObject := TCustomListBox(callback.GetTarget);
DrawStruct.ItemState := [];
if isRowSelected(row) then
Include(DrawStruct.ItemState, odSelected);
if not LCLObject.Enabled then
Include(DrawStruct.ItemState, odDisabled);
if (LCLObject.Focused) and (LCLObject.ItemIndex = row) then
Include(DrawStruct.ItemState, odFocused);
LCLSendDrawListItemMsg(TWinControl(callback.GetTarget), @DrawStruct);
end;
procedure TCocoaListBox.dealloc;
begin
FreeAndNil(list);