View Issue Details

IDProjectCategoryView StatusLast Update
0032829LazarusWidgetsetpublic2017-12-23 06:32
ReporterDavid Jenkins Assigned ToDmitry Boyarintsev  
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionfixed 
Summary0032829: Changes made to ComboBox edit field are not passed through lcl layer and not captured.
DescriptionIf text is changed in a ComboBox edit field the changes are not captured and hitting return does nothing. Debugging shows no keystrokes are passing down through lcl layer.

Need to catch when key events happen and pass them down through. But overriding keydown() and keyup() for NSComboBox does not work as the common FieldEditor is getting those key strokes not the NSComboBox.

NSComboBox does get textDidChange() and textDidEndEditing() notifications and NSApp.currentEvent will return the key NSEvent that can be passed to callback.keyEvent().

Patch attached.
TagsNo tags attached.
Fixed in Revision56822
Attached Files


David Jenkins

2017-12-14 23:07


ComboBox.diff (1,541 bytes)   
Index: cocoaprivate.pp
--- cocoaprivate.pp	(revision 22741)
+++ cocoaprivate.pp	(working copy)
@@ -522,6 +524,8 @@
     function acceptsFirstResponder: Boolean; override;
     function becomeFirstResponder: Boolean; override;
     function resignFirstResponder: Boolean; override;
+    procedure textDidChange(notification: NSNotification); override;
+    procedure textDidEndEditing(notification: NSNotification); override;
     // NSComboBoxDataSourceProtocol
     function comboBox_objectValueForItemAtIndex_(combo: TCocoaComboBox; row: NSInteger): id; message 'comboBox:objectValueForItemAtIndex:';
     function numberOfItemsInComboBox(combo: TCocoaComboBox): NSInteger; message 'numberOfItemsInComboBox:';
@@@ -3623,6 +3634,27 @@
+procedure TCocoaComboBox.textDidChange(notification: NSNotification);
+  TheEvent: NSEvent;
+  inherited textDidChange(notification);
+  TheEvent := nsapp.currentevent;
+  if assigned(callback) and (TheEvent.type_ = NSKeyDown) then
+    callback.KeyEvent(TheEvent)
+procedure TCocoaComboBox.textDidEndEditing(notification: NSNotification);
+  TheEvent: NSEvent;
+  inherited textDidEndEditing(notification);
+  TheEvent := nsapp.currentevent;
+  if assigned(callback) and (TheEvent.type_ = NSKeyDown) then
+    callback.KeyEvent(TheEvent)
 function TCocoaComboBox.comboBox_objectValueForItemAtIndex_(combo:TCocoaComboBox;
   row: NSInteger):id;
ComboBox.diff (1,541 bytes)   

Dmitry Boyarintsev

2017-12-23 06:32

developer   ~0104956

thank you for the patch. applied.
please test and close if ok

Issue History

Date Modified Username Field Change
2017-12-14 23:07 David Jenkins New Issue
2017-12-14 23:07 David Jenkins File Added: ComboBox.diff
2017-12-15 15:15 Dmitry Boyarintsev Assigned To => Dmitry Boyarintsev
2017-12-15 15:15 Dmitry Boyarintsev Status new => assigned
2017-12-23 06:32 Dmitry Boyarintsev Fixed in Revision => 56822
2017-12-23 06:32 Dmitry Boyarintsev LazTarget => -
2017-12-23 06:32 Dmitry Boyarintsev Note Added: 0104956
2017-12-23 06:32 Dmitry Boyarintsev Status assigned => resolved
2017-12-23 06:32 Dmitry Boyarintsev Resolution open => fixed