ComboBox: more fixes with TComboBoxStyle.HasEditBox

git-svn-id: trunk@63225 -
This commit is contained in:
ondrej 2020-05-26 21:53:31 +00:00
parent 34e6f40639
commit 1c63f54328
11 changed files with 19 additions and 19 deletions

View File

@ -247,7 +247,7 @@ end;
procedure TCustomComboBox.CloseUp;
begin
if [csLoading,csDestroying,csDesigning]*ComponentState<>[] then exit;
if Style in [csSimple, csDropDown, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable] then
if Style.HasEditBox then
begin
EditingDone;
FEditingDone := False;
@ -297,7 +297,7 @@ end;
function TCustomComboBox.GetSelText: string;
begin
//debugln('TCustomComboBox.GetSelText ');
if FStyle in [csDropDown, csSimple] then
if FStyle.HasEditBox then
Result:= UTF8Copy(Text, SelStart + 1, SelLength)
else
Result:= '';
@ -316,7 +316,7 @@ var
OldSelStart: integer;
begin
//debugln('TCustomComboBox.SetSelText ',Val);
if FStyle in [csDropDown, csSimple] then
if FStyle.HasEditBox then
begin
OldText := Text;
OldSelStart := SelStart;
@ -397,7 +397,7 @@ var
CurText: String;
begin
//debugln('TCustomComboBox.SelectAll ');
if (FStyle in [csDropDown, csSimple]) then
if FStyle.HasEditBox then
begin
CurText := Text;
if (CurText <> '') then

View File

@ -678,7 +678,7 @@ var
CFString: CFStringRef;
TmpSpec: EventTypeSpec;
begin
FReadOnly := (LCLObject as TCustomComboBox).Style in [csDropDownList, csOwnerDrawFixed, csOwnerDrawVariable];
FReadOnly := not (LCLObject as TCustomComboBox).Style.HasEditBox;
FLastDroppedDown := False;
if FReadOnly then

View File

@ -442,7 +442,7 @@ var
begin
if not CheckHandle(ACustomComboBox, Self, 'SetStyle') then Exit;
TCarbonComboBox(ACustomComboBox.Handle).SetReadOnly(ACustomComboBox.Style in [csDropDownList, csOwnerDrawFixed, csOwnerDrawVariable]);
TCarbonComboBox(ACustomComboBox.Handle).SetReadOnly(not ACustomComboBox.Style.HasEditBox);
sz:=TCarbonComboBox(ACustomComboBox.Handle).GetPreferredSize;
ACustomComboBox.Constraints.SetInterfaceConstraints(0,0,0,sz.Y);
end;

View File

@ -486,7 +486,7 @@ end;
function ComboBoxStyleIsReadOnly(AStyle: TComboBoxStyle): Boolean;
begin
Result := AStyle in [csDropDownList, csOwnerDrawFixed, csOwnerDrawVariable];
Result := not AStyle.HasEditBox;
end;
function ComboBoxIsReadOnly(cmb: TCustomComboBox): Boolean;

View File

@ -1687,7 +1687,7 @@ begin
else
InputObject := AGtkObject;
if TCustomComboBox(AWinControl).Style in [csDropDownList, csOwnerDrawFixed, csOwnerDrawVariable] then
if not TCustomComboBox(AWinControl).Style.HasEditBox then
begin
// Just a combobox without a edit should handle its own keys. Issue #32458
Gtk2WidgetSet.SetCallbackDirect(LM_KEYDOWN, InputObject, AWinControl);
@ -1711,7 +1711,7 @@ begin
// And now the same for the Button in the combo
if AButton<>nil then begin
if TCustomComboBox(AWinControl).Style in [csDropDownList, csOwnerDrawFixed, csOwnerDrawVariable] then
if not TCustomComboBox(AWinControl).Style.HasEditBox then
begin
// Just a combobox without a edit should handle its own keys. Issue #32458
Gtk2WidgetSet.SetCallbackDirect(LM_KEYDOWN, AButton, AWinControl);

View File

@ -6210,12 +6210,12 @@ begin
FWidgetType := FWidgetType + [wtTreeModel, wtComboBox];
ACombo := TCustomComboBox(LCLObject);
ListStore := gtk_list_store_new (2, [G_TYPE_STRING, G_TYPE_POINTER, nil]);
if ACombo.Style in [csDropDown, csSimple] then
if ACombo.Style.HasEditBox then
Result := PGtkWidget(TGtkComboBox.new_with_model_and_entry(PGtkTreeModel(ListStore)))
else
Result := PGtkWidget(TGtkComboBox.new_with_model(PGtkTreeModel(ListStore)));
if ACombo.Style in [csDropDown, csSimple] then
if ACombo.Style.HasEditBox then
begin
ItemList := TGtkListStoreStringList.Create(PGtkListStore(PGtkComboBox(Result)^.get_model), 0, LCLObject);
g_object_set_data(PGObject(Result), GtkListItemLCLListTag, ItemList);

View File

@ -1638,7 +1638,7 @@ end;
class procedure TQtWSCustomComboBox.SetStyle(
const ACustomComboBox: TCustomComboBox; NewStyle: TComboBoxStyle);
begin
TQtComboBox(ACustomComboBox.Handle).setEditable(NewStyle in [csDropDown, csSimple, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable]);
TQtComboBox(ACustomComboBox.Handle).setEditable(NewStyle.HasEditBox);
TQtComboBox(ACustomComboBox.Handle).OwnerDrawn := NewStyle in
[csOwnerDrawFixed,
csOwnerDrawVariable,
@ -1699,7 +1699,7 @@ begin
ACombo := QComboBox_create(nil);
try
QWidget_setFont(ACombo, ComboBox.getFont);
QComboBox_setEditable(ACombo, not ACustomComboBox.Style.HasEditBox);
QComboBox_setEditable(ACombo, ACustomComboBox.Style.HasEditBox);
AText := 'Mtjx';
AItems := QStringList_create(@AText);
QComboBox_addItems(ACombo, AItems);

View File

@ -1583,7 +1583,7 @@ end;
class procedure TQtWSCustomComboBox.SetStyle(
const ACustomComboBox: TCustomComboBox; NewStyle: TComboBoxStyle);
begin
TQtComboBox(ACustomComboBox.Handle).setEditable(NewStyle in [csDropDown, csSimple, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable]);
TQtComboBox(ACustomComboBox.Handle).setEditable(NewStyle.HasEditBox);
TQtComboBox(ACustomComboBox.Handle).OwnerDrawn := NewStyle in
[csOwnerDrawFixed,
csOwnerDrawVariable,
@ -1644,7 +1644,7 @@ begin
ACombo := QComboBox_create(nil);
try
QWidget_setFont(ACombo, ComboBox.getFont);
QComboBox_setEditable(ACombo, not ACustomComboBox.Style.HasEditBox);
QComboBox_setEditable(ACombo, ACustomComboBox.Style.HasEditBox);
AText := 'Mtjx';
AItems := QStringList_create(PWideString(@AText));
QComboBox_addItems(ACombo, AItems);

View File

@ -1323,7 +1323,7 @@ begin
itemindex is updated, so set text manually }
CBN_SELCHANGE:
begin
if TCustomComboBox(lWinControl).Style in [csSimple, csDropDown] then
if TCustomComboBox(lWinControl).Style.HasEditBox then
UpdateComboBoxText(TCustomComboBox(lWinControl));
SendSimpleMessage(lWinControl, LM_CHANGED);
LMessage.Msg := LM_SELCHANGE;

View File

@ -391,7 +391,7 @@ var
SaveText: String;
SavePos, SaveLen: Integer;
begin
if TCustomComboBox(FSender).Style in [csSimple, csDropDown, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable] then
if TCustomComboBox(FSender).Style.HasEditBox then
begin
SaveText := TCustomComboBox(FSender).Text;
SavePos := TCustomComboBox(FSender).SelStart;
@ -399,7 +399,7 @@ begin
end;
inherited;
UpdateComboHeight;
if TCustomComboBox(FSender).Style in [csSimple, csDropDown, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable] then
if TCustomComboBox(FSender).Style.HasEditBox then
begin
TCustomComboBox(FSender).Text := SaveText;
TCustomComboBox(FSender).SelStart := SavePos;

View File

@ -1110,7 +1110,7 @@ var
begin
if WSCheckHandleAllocated(ACustomComboBox, 'TWin32WSCustomComboBox.SetDroppedDown') then
begin
Editable := (ACustomComboBox.Style in [csDropDown, csOwnerDrawEditableFixed, csOwnerDrawEditableVariable]);
Editable := (ACustomComboBox.Style.HasEditBox);
if Editable then
begin
if not GetText(ACustomComboBox, aText) then