Hello,

I implemented ListBox.Onclick and ListBox.OnSelectionChange, but they
do not work correctly.  OnSelectionChange sends messages of all types
and OnClick does not want to send Onclick (But I see the sign in Qt
when I click an item).  View file "ListBoxonclick.diff". If someone
understands what is happening that he fix him because no longer I know
what to do.

White flag. :(
--
http://luisdigital.com
Index: ide/revision.inc
===================================================================
--- ide/revision.inc	(revision 9935)
+++ ide/revision.inc	(working copy)
@@ -1,2 +1,2 @@
 // Created by Svn2RevisionInc
-const RevisionStr = '9891';
+const RevisionStr = '9917M';
Index: lcl/interfaces/qt/qtobjects.pas
===================================================================
--- lcl/interfaces/qt/qtobjects.pas	(revision 9935)
+++ lcl/interfaces/qt/qtobjects.pas	(working copy)
@@ -26,6 +26,7 @@
     function Get(Index : Integer) : string; override;
     //procedure SetSorted(Val : boolean); virtual;
   public
+    LCLObject: TWinControl;
     constructor Create(ListWidgetH : QListWidgetH; TheOwner: TWinControl);
     destructor Destroy; override;
     procedure Assign(Source : TPersistent); override;
@@ -471,11 +472,7 @@
 end;
 
 function TQtListStrings.Get(Index: Integer): string;
-{var
-  QListWidgetItem: QListWidgetItemH;}
 begin
-{  QListWidgetItem := QListWidget_item(FQtListWidget, Index);
-  Result := QListWidgetItem;}
   if FListChanged then InternalUpdate;
   if Index < FStringList.Count then
      Result := FStringList.Strings[Index]
@@ -501,9 +498,14 @@
   FOwner:=TheOwner;
   // Callback Event
   {Method := ListChanged;}
+(*  TEventFilterMethod(Method) := ListChangedHandler;
+  Hook := QListWidget_hook_create(FQtListWidget);
+  QListWidget_hook_hook_itemChanged(Hook,Method); *)
+  // Callback Event
+  {Method := ListChanged;}
   TEventFilterMethod(Method) := ListChangedHandler;
   Hook := QListWidget_hook_create(FQtListWidget);
-  QListWidget_hook_hook_itemChanged(Hook,Method);
+  QListWidget_hook_hook_currentItemChanged(Hook,Method);
 end;
 
 destructor TQtListStrings.Destroy;
@@ -562,8 +564,17 @@
 
 function TQtListStrings.ListChangedHandler(Sender: QObjectH; Event: QEventH
   ): Boolean; cdecl;
+var
+  Mess: TLMessage;
 begin
-
+ //  if not FUpdating then begin
+//    FTextChanged := True;
+    FillChar(Mess, SizeOf(Mess), #0);
+    Mess.Msg := LM_SELCHANGE;
+    //(FOwner as TCustomMemo).Modified := True;
+    FOwner.Dispatch(TLMessage(Mess));
+//    end;
+  Result := True;
 end;
 
 end.
Index: lcl/interfaces/qt/qtprivate.pp
===================================================================
--- lcl/interfaces/qt/qtprivate.pp	(revision 9935)
+++ lcl/interfaces/qt/qtprivate.pp	(working copy)
@@ -286,11 +286,14 @@
   end;
 
   
+  { TQtListWidget }
+
   TQtListWidget = class(TQtListView)
   private
   public
     constructor Create(const AWinControl: TWinControl; const AParams: TCreateParams); override;
     destructor Destroy; override;
+    procedure SlotClicked(ModelIndex: QModelIndexH); cdecl;
   public
     function currentRow: Integer;
     procedure setCurrentRow(row: Integer);
@@ -2187,6 +2190,19 @@
   inherited Destroy;
 end;
 
+procedure TQtListWidget.SlotClicked(ModelIndex: QModelIndexH); cdecl;
+var
+  Msg: TLMessage;
+begin
+  Msg.Msg := LM_CLICKED;
+
+  try
+    LCLObject.WindowProc(TLMessage(Msg));
+  except
+    Application.HandleException(nil);
+  end;
+end;
+
 {------------------------------------------------------------------------------
   Function: TQtListWidget.currentRow
   Params:  None
Index: lcl/interfaces/qt/qtwsstdctrls.pp
===================================================================
--- lcl/interfaces/qt/qtwsstdctrls.pp	(revision 9935)
+++ lcl/interfaces/qt/qtwsstdctrls.pp	(working copy)
@@ -107,6 +107,7 @@
 
   TQtWSCustomListBox = class(TWSCustomListBox)
   private
+    class procedure SetSlots(const QtListWidget: TQtListWidget);
   protected
   public
     class function  CreateHandle(const AWinControl: TWinControl;
@@ -306,6 +307,15 @@
 
 { TQtWSCustomListBox }
 
+class procedure TQtWSCustomListBox.SetSlots(const QtListWidget: TQtListWidget);
+var
+  Method: TMethod;
+begin
+  QAbstractItemView_clicked_Event(Method) := QtListWidget.SlotClicked;
+
+  QAbstractItemView_hook_hook_clicked(QListWidget_hook_create(QtListWidget.Widget), Method);
+end;
+
 {------------------------------------------------------------------------------
   Method: TQtWSCustomListBox.CreateHandle
   Params:  None
@@ -316,6 +326,7 @@
   QtListWidget: TQtListWidget;
 begin
   QtListWidget := TQtListWidGet.Create(AWinControl, AParams);
+  SetSlots(QtListWidget);
   Result := THandle(QtListWidget);
 end;
 

Reply via email to