introduce intfselectionchanged procedure for widgetsets that do not send LM_SELCHANGED automatically

fix senditemindex to cause onclick event

git-svn-id: trunk@7154 -
This commit is contained in:
micha 2005-05-06 09:39:49 +00:00
parent 647a5f96c1
commit 6c015e6ea2
3 changed files with 31 additions and 15 deletions

View File

@ -33,14 +33,22 @@ procedure TCustomListBox.AssignCacheToItemData(const AIndex: Integer;
const AData: Pointer);
begin
if PCustomListBoxItemRecord(AData)^.Selected or (FItemIndex = AIndex) then
begin
LockSelectionChange;
SendItemSelected(AIndex, True);
UnlockSelectionChange;
end;
end;
procedure TCustomListBox.Loaded;
begin
inherited Loaded;
if HandleAllocated then
begin
LockSelectionChange;
SendItemIndex;
UnlockSelectionChange;
end;
end;
{------------------------------------------------------------------------------
@ -202,10 +210,7 @@ begin
end;
end;
{------------------------------------------------------------------------------
procedure TCustomListBox.LMSelChange(var TheMessage);
------------------------------------------------------------------------------}
procedure TCustomListBox.LMSelChange(var TheMessage);
procedure TCustomListBox.IntfSelectionChanged;
begin
if [csLoading,csDestroying,csDesigning]*ComponentState<>[] then exit;
//debugln('TCustomListBox.LMSelChange ',Name,':',ClassName,' ItemIndex=',dbgs(ItemIndex),' FLockSelectionChange=',dbgs(FLockSelectionChange));
@ -214,6 +219,14 @@ begin
DoSelectionChange(FLockSelectionChange=0);
end;
{------------------------------------------------------------------------------
procedure TCustomListBox.LMSelChange(var TheMessage);
------------------------------------------------------------------------------}
procedure TCustomListBox.LMSelChange(var TheMessage);
begin
IntfSelectionChanged;
end;
{------------------------------------------------------------------------------
procedure TCustomListBox.SendItemSelected(Index: integer; IsSelected: boolean);
@ -221,11 +234,8 @@ end;
------------------------------------------------------------------------------}
procedure TCustomListBox.SendItemSelected(Index: integer; IsSelected: boolean);
begin
if HandleAllocated then begin
LockSelectionChange;
if HandleAllocated then
TWSCustomListBoxClass(WidgetSetClass).SelectItem(Self, Index, IsSelected);
UnlockSelectionChange;
end;
end;
{------------------------------------------------------------------------------}
@ -367,13 +377,8 @@ end;
procedure TCustomListBox.SendItemIndex;
begin
LockSelectionChange;
try
// TODO 64bit
TWSCustomListBoxClass(WidgetSetClass).SetItemIndex(Self, FItemIndex);
finally
UnlockSelectionChange;
end;
// TODO 64bit
TWSCustomListBoxClass(WidgetSetClass).SetItemIndex(Self, FItemIndex);
end;
{------------------------------------------------------------------------------}

View File

@ -508,6 +508,9 @@ begin
Windows.SendMessage(Handle, LB_SETSEL, Windows.WParam(true), Windows.LParam(AIndex));
end else
Windows.SendMessage(Handle, LB_SETCURSEL, Windows.WParam(AIndex), 0);
// windows does not send selection changed notify message
ACustomListBox.IntfSelectionChanged;
end;
procedure TWin32WSCustomListBox.SetSelectionMode(const ACustomListBox: TCustomListBox;

View File

@ -450,6 +450,10 @@ type
procedure Clear; virtual;
procedure LockSelectionChange;
procedure UnlockSelectionChange;
public
{ to be called by widgetset backend }
// equivalent of LM_SELCHANGED
procedure IntfSelectionChanged; virtual;
public
property Align;
property Anchors;
@ -1252,6 +1256,10 @@ end.
{ =============================================================================
$Log$
Revision 1.204 2005/05/06 09:39:49 micha
introduce intfselectionchanged procedure for widgetsets that do not send LM_SELCHANGED automatically
fix senditemindex to cause onclick event
Revision 1.203 2005/05/02 09:17:08 mattias
started TButtonActionLink