Hi all,
Have anyone tried to show the listbox of combobox programmatically? I managed to some point, but I need to manually select the combobox the first time inorder to set the dimensions of the listbox.
Yoyong

Mailing lists / lazarus / 2003-06
20 messages · 5 people ·
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Hi all,
Have anyone tried to show the listbox of combobox programmatically? I managed to some point, but I need to manually select the combobox the first time inorder to set the dimensions of the listbox.
Yoyong
----- Original Message -----
From:
To:
Sent: Wednesday, June 04, 2003 5:39 PM
Subject: [lazarus] Programmatically showing the listbox of combobox
Hi all, Have anyone tried to show the listbox of combobox programmatically? I
managed to
some point, but I need to manually select the combobox the first time
inorder to
set the dimensions of the listbox.
I would like to know how to show the listbox, can you show me?.
Thanks
Jesus Reyes A.
In gtkwinapi.inc function TgtkObject.ComboBoxDropDown(Handle: HWND; DropDown: boolean):…
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
There is a new version at ftp of fpc 1.08 (with date 6/5/2003). Do anyone know if this is the stable 1.08 version?
- --
Saludos
Manuel P�rez L�pez
- -----------------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
iD8DBQE+34nzYvl2oJ24QTwRAiGRAJ4wWnNy28qiAUxetluc6IHVHfyrzQCeIqPh 5ET8fF0Yz1esMlpLrifsL+M=
=3wH+
-----END PGP SIGNATURE-----
To Jesus,
In gtkwinapi.inc
function TgtkObject.ComboBoxDropDown(Handle: HWND; DropDown: boolean): boolean;
var
ComboWidget: PGtkCombo;
begin
Result:=false;
if Handle=0 then exit;
ComboWidget:=PGtkCombo(Handle);
if DropDownGTK_WIDGET_VISIBLE(ComboWidget^.popwin) then begin
if DropDown then begin
writeln('TgtkObject.ComboBoxDropDown ToDo: Find the trick to popup the combobox');
//code is here
gtk_widget_show(ComboWidget^.popwin);
//this will show the popwindow at the upper left side , a very small window
//but if you first click the dropdown list and set to true ComboBoxDroppedDown of TCustomComboBox list box is okay
end else
gtk_widget_hide (ComboWidget^.popwin);
end;
Result:=true;
end;I will send tomorrow my complete changes. As I have also changed some properties for the TCustomComboBox (My Lazarus machine is at home, I am still at my office)
Regards,
Yoyong
Internet Mail Message
Received from host:
svcr-216-37-230-2.dsl.svcr.epix.net
[216.37.230.2]
From: "Jesus Reyes" on 06/05/2003 05:43 AM GMT
"Jesus Reyes" To:
Cc: (bcc: Yoyong Hernan-ET/PGI)
Subject: RE: [lazarus] Programmatically
showing the listbox of combobox
06/05/2003 01:43 PM
Please respond to
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 There is a new version at ftp of fpc 1.08…
Normally, yes.
The announcement will hopefully be made tomorrow.
Michael.
What is this patch for?
This patch will enable to programmatically show the list box of the combobox control.
How to use?
Set DroppedDown to true, e.g., combobox1.DroppedDown := True;
this cause the list box to show up.
Set DroppedDown to false to hide the list box, e.g, combobox1.DroppedDown := False;changes to stdctrls.pp
213d212
< procedure CreateWnd; override;
260a259
property Style: TComboBoxStyle read FStyle write SetStyle;
281d279
< property Style: TComboBoxStyle read FStyle write SetStyle;changes to customcombobox.inc
77,81c77,79
< procedure TCustomComboBox.CreateWnd;
< begin
< inherited CreateWnd;
< CNSendMessage(LM_SETPROPERTIES, Self, nil);
< end;
---{------------------------------------------------------------------------------ procedure TCustomComboBox.DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState);
83,87d81
< {------------------------------------------------------------------------------ < procedure TCustomComboBox.DrawItem(Index: Integer; Rect: TRect; < State: TOwnerDrawState);
<
<
367,368c361
< if HandleAllocated then
< CNSendMessage(LM_SETPROPERTIES, Self, nil); ---
// ToDo
changes to gtkobject.inc
6030,6031c6030,6031
< csCombobox :
< with TCustomComboBox(Sender) do
---
csEdit : with TCustomEdit(Sender) do
6033,6045c6033,6040
< case TCustomComboBox(Sender).Style of
< csDropDownList :
< begin
< gtk_combo_set_value_in_list(PgtkCombo(Handle),-1, 0);
< gtk_combo_set_use_arrows_always(PgtkCombo(Handle),-1);
< gtk_combo_set_case_sensitive(PGtkCombo(Handle),0);
< end;
< else
< begin
< gtk_combo_set_value_in_list(PgtkCombo(Handle),0,0);
< gtk_combo_set_use_arrows_always(PgtkCombo(Handle),0);
< end;
< end;
---6047,6059d6042
< csEdit :
< with TCustomEdit(Sender) do
< begin
< // XXX TODO: GTK 1.x does not support EchoMode emNone. < // This will have to be coded around, but not a priority <
< gtk_entry_set_editable(PgtkEntry(Handle), not (TCustomEdit(Sender).ReadOnly)); < gtk_entry_set_max_length(PgtkEntry(Handle), TCustomEdit(Sender).MaxLength); < gtk_entry_set_visibility(PGtkEntry(Handle), < (TCustomEdit(Sender).EchoMode = emNormal) < and (TCustomEdit(Sender).PassWordChar=#0)); < end;
<
changes to gtkwinapi.inc
1941,1942c1941,1954
< procedure gtk_combo_get_pos(combo : PGtkCombo; var x : gint; var y : gint; var height : gint; var width : gint); < var
---
1944,1962c1956,1959
< popwin : PGtkbin;
< widget : PGtkWidget;
< popup : PGtkScrolledwindow;
< real_height : gint;
< list_requisition : PGtkRequisition;
< show_hscroll : gboolean;
< show_vscroll : gboolean;
< avail_height : gint;
< min_height : gint;
< alloc_width : gint;
< work_height : gint;
< old_height : gint;
< old_width : gint;
< okay_to_exit : boolean;
< const
< EMPTY_LIST_HEIGHT = 15;
< begin
< show_hscroll := False;
< show_vscroll := False;
---{------------------------------------------------------------------------------ Function: ExtSelectClipRGN Params: dc, RGN, Mode Returns: integer
1964,1976c1961,1962
< widget := GTK_WIDGET(combo);
< popup := GTK_SCROLLED_WINDOW (combo^.popup);
< popwin := GTK_BIN (combo^.popwin);
< gdk_window_get_origin (combo^.entry^.window, @x, @y);
< real_height := MIN (combo^.entry^.requisition.height,
< combo^.entry^.allocation.height);
< y := y + real_height;
< avail_height := gdk_screen_height () - y;
< New(list_requisition);
< gtk_widget_size_request (combo^.list, list_requisition);
< min_height := list_requisition^.height;
< // if min_height < popup^.vscrollbar^.requisition.height then
< // min_height := popup^.vscrollbar^.requisition.height;
---Combines the passed Region with the current clipping region in the device context (dc), using the specified mode.
1978,1980c1964,1965
< min_height := MIN (list_requisition^.height,popup^.vscrollbar^.requisition.height);
< if GTK_LIST (combo^.list)^.children = nil then
< list_requisition^.height := list_requisition^.height + EMPTY_LIST_HEIGHT;
---The Combine Mode can be one of the following: RGN_AND : all points which are in both regions
1982,1987c1967
< alloc_width := (widget^.allocation.width -
< 2 * PGtkStyle(popwin^.child^.thestyle)^.klass^.xthickness - < 2 * border_width(GTK_CONTAINER (popwin^.child)^) - < 2 * border_width(GTK_CONTAINER (combo^.popup)^) - < 2 * border_width(GTK_CONTAINER (GTK_BIN (popup)^.child)^) - < 2 * PGtkStyle(GTK_BIN (popup)^.child^.thestyle)^.klass^.xthickness); ---
RGN_COPY : an exact copy of the source region, same as SelectClipRGN
1989,1993c1969,1970
< work_height := (2 * (PGtkStyle(popwin^.child^.thestyle)^.klass^.ythickness) + < 2 * border_width(GTK_CONTAINER (popwin^.child)^) + < 2 * border_width(GTK_CONTAINER (combo^.popup)^) + < 2 * border_width(GTK_CONTAINER (GTK_BIN (popup)^.child)^) + < 2 * PGtkStyle(GTK_BIN (popup)^.child^.thestyle)^.klass^.xthickness); ---
RGN_DIFF : all points which are in the Clipping Region but but not in the Source.(Clip - RGN)
1995,1998c1972,1973
< repeat
< okay_to_exit := True;
< old_width := alloc_width;
< old_height := work_height;
---RGN_OR : all points which are in either the Clip Region or in the Source.(Clip + RGN)
2000,2020c1975,1976
< if ((not show_hscroll) and (alloc_width < list_requisition^.width)) then
< begin
< work_height := work_height + popup^.hscrollbar^.requisition.height +
< GTK_SCROLLED_WINDOW_CLASS(GTK_OBJECT (combo^.popup)^.klass)^.scrollbar_spacing;
< show_hscroll := TRUE;
< okay_to_exit := False;
< end;
< if ((not show_vscroll) and (workI have tried to use diff -ur --exclude=CVS /orig_lazarus/ /changed_laz/ | gzip > laz.diff.gz but I am generated a large file, maybe my working copy is quite old.
If it is better to send the generated file, please let me know.
Yoyong
Nice! I look forward to seeing this in the CVS soon.
What is this patch for? This patch will enable to programmatically show the list box of…
Can you send a cvs -z3 diff -u | gzip > laz.diff.gz ?
Mattias
I have played around the combobox implementation and here is what I got. If you need to…
----- Original Message -----
From:
To:
Sent: Wednesday, June 11, 2003 5:51 PM
Subject: RE: [lazarus] Programmatically showing the listbox of combobox
would you
need to check the value of FDroppedDown.
I need the combobox to send the keyboard events to the parent grid in order to allow
normal grid navigation
I will be happy if I could get the following::
1. the combobox IS dropped down.
1.1. UP/DOWN key events => Item focus
1.2. LEFT/RIGHT key events => Item focus or Grid navigation ???
1.3. ENTER key event => Focused item is now the selected Item, hide listbox.
1.4. ESC key event => Selected item remains without changes, hide listbox
1.5. CTRL+DOWN => Same as ESC
1.6. Typing Text => Incremental search (item focusing)
2. the combobox IS NOT dropped down.
2.1. UP/DOWN key events => Grid navigation 2.2. LEFT/RIGHT key events => Grid navigation 2.3. ENTER key event => unhandled or same as 2.5 ??? 2.4. ESC key event => unhandled
2.5. CTRL+DOWN => drop down the listbox to allow 1.1,1.2 or 1.6
2.6. Typing Text =>{Dropdown the listbox ???,}Inc. search (item selection)
The way is now, it sometimes does Item selection and sometimes Grid navigation, depending on the current item selection! (2.1).
If the lcl combobox will get all key events (being the listbox droppedown or not), I need a way to know when to do Item Selection or grid navigation and this depends on DroppedDown Property, at least in the way I planned.
In my program, when I set Style to csDroppedDown, AutoDropDown = True, and I type something on the entry box
I
cannot get out of the listbox not unless I select an item from the list. Also, if you need to trap VK_UP or VK_DOWN, the attached file adds another
property
for the combo box name ArrowKeysTraverseList with a default value of
True. This
is the defualt behaviour of the combo box(gtk widget default behaviour), especially if you set style to csdropdownlist. Now if you set ArrowKeysTraverseList to False and AutoDroppedDown to false and I am not
sure
style to csdroppedownlist you should be able to trap VK_UP or VK_DOWN. And
also
Thank you, It sounds nice I will update as soon the patches are in cvs ;)
What do you think, are we asking to much to gtk?. I'm asking this because for example, if I need a multicolumn listbox, with headers, footers and other goodies, does the underlaying gtkwidget provide such functionality or we need to wrap another one. if this is the case, aren't we being too gtk dependant? I mean what if others interfaces doesn't have a so-similar widget?.
Thanks.
Jesus Reyes A.
Hi Jesus,
I have played around the combobox implementation and here is what I got.
If you need to trap arrow keys, we need the attached patch. And as for the FDroppedDown not updated, I am still working on it. If I may ask, why would you need to check the value of FDroppedDown. In my program, when I set Style to csDroppedDown, AutoDropDown = True, and I type something on the entry box I cannot get out of the listbox not unless I select an item from the list. Also, if you need to trap VK_UP or VK_DOWN, the attached file adds another property for the combo box name ArrowKeysTraverseList with a default value of True. This is the defualt behaviour of the combo box(gtk widget default behaviour), especially if you set style to csdropdownlist. Now if you set ArrowKeysTraverseList to False and AutoDroppedDown to false and I am not sure style to csdroppedownlist you should be able to trap VK_UP or VK_DOWN. And also the patch implemented the key sequence Ctrl+Down to show the popup.
Regards
Yoyong
Internet Mail Message
Received from host:
svcr-216-37-230-2.dsl.svcr.epix.net
[216.37.230.2]
From: "Jesus Reyes" on 06/11/2003 05:14 AM GMT
"Jesus Reyes" To:
Cc: (bcc: Yoyong Hernan-ET/PGI)
Subject: RE: [lazarus] Programmatically
showing the listbox of combobox
06/11/2003 01:14 PM
Please respond to
Do you mean, the listbox is not closed/hidden? If you set csdropdownlist and the text in…
(though I am not sure what is the purpose of autodropdown, "Mattias can you explain what is the purpose of autodropdown?")
It came in Delphi6 and is defined as:
When AutoDropDown is true the combobox drops down its list when the user starts typing a string.
Otherwise the user must explicitly use the drop down button.
Mattias
If I understand it right, I have to set csdropdownlist and autodropdown property to drop…
Hi, I have noticed that sometimes (for example when clicking out of the listbox) the DroppedDown property doesnt get updated. Also it seems that the listbox doesnt get the keyboard focus when pop up.
While you are in this [ and if you have enought time ;)] could you check if it is possible to trap all keyboard events before the gtkwidget? It happen that TComboBox only have the keyboard control when the itemindex=0 {VK_UP} or ItemIndex=Count-1 {VK_DOWN}.
In windows I was used to the ALT+DOWN hot key to dropdown the listbox, in linux it seems it is not possible, which would be a appropiated hotkey to this?.
I dont know if I need to make some adjustment somewhere, It seems that Undo functionality is missing in Gtk (for TEdit)?
Thanks.
--- escribi�: > Hi Mattias,
_________________________________________________________ Do You Yahoo!?
La mejor conexi�n a internet y 25MB extra a tu correo por $100 al mes. http://net.yahoo.com.mx
I have played around the combobox implementation and here is what I got. If you need to…
Hi @all,
where can i get the latest source from Lazarus because the link on the website did not work
Greats Harry
I have played around the combobox implementation and here is what I got. If you need to…
Hi @all, where can i get the latest source from Lazarus because the link on the website did not work
I fixed the link.
Mattias
I have played around the combobox implementation and here is what I got. If you need to…
hi,
i get the diff patch from the ftp server.
How can i patch the Lazarus Source with this.
harry
Hi Jesus,
Hi, I have noticed that sometimes (for example when clicking out of the listbox) the DroppedDown property doesnt get updated. Also it seems that the listbox doesnt get the keyboard focus when pop up.
Do you mean, the listbox is not closed/hidden? If you set csdropdownlist and the text in the entry is not in the list, it will not close/update the combobox.
While you are in this [ and if you have enought time ;)] could you check if it is possible to trap all keyboard events before the gtkwidget? It happen that TComboBox only have the keyboard control when the itemindex=0 {VK_UP} or ItemIndex=Count-1 {VK_DOWN}.
Please expound, I don't quite understand what you mean. Or better yet, what do you want to do, maybe I can be of help.
In windows I was used to the ALT+DOWN hot key to dropdown the listbox, in linux it seems it is not possible, which would be a appropiated hotkey to this?.
I think this is a GTK stuff, maybe we can simulate, but its going to be ugly. But do note, that when you set csdropdownlist and maybe autodropdown (though I am not sure what is the purpose of autodropdown, "Mattias can you explain what is the purpose of autodropdown?") the listbox should automatically show up when you press any key without the need to press ALT+DOWN .
I dont know if I need to make some adjustment somewhere, It seems that Undo functionality is missing in Gtk (for TEdit)?
Maybe I can also check ,
Yoyong
Hi Mattias,
If I understand it right, I have to set csdropdownlist and autodropdown property to drop the listbox automatically?
Regards,
Yoyong
In Delphi the csdropdonwlist style is defined as a combobox with readonly text field.
Do you mean the AutoDropDown property?
procedure TCustomComboBox.WMChar(var Message: TLMChar);
The LCL tries to use methods instead of messages. I overrode the KeyDown method. Maybe you can have a look.
Please forgive me again this time for not sending a patch file.
I forgive. ;)
Any help is welcome.
Mattias
This is indeed a problem, I will try to check this at home.
I will also try to experiment , I am using Windows while a work.
Regards,
Yoyong
Do you mean, the listbox is not closed/hidden? If you set csdropdownlist and the text in…
----- Original Message -----
From:
To:
Sent: Tuesday, June 10, 2003 7:24 PM
Subject: Re: [lazarus] Programmatically showing the listbox of combobox
and the text in the entry is not in the list, it will not close/update the combobox.
I mean, if I use MyCombo.DroppedDown:=True (internally, FDroppedDown:=True); The listbox shows up, But if I click Outside of the Listbox, the listbox disappers normally, its ok, the problem is that internally FDroppedDown doesn't get updated to False so if I test MyCombo.DroppedDown it returns True, even when the listbox is hidden!.
what do you want to do, maybe I can be of help.
A little example, suppose you have a ComboBox filled with 5 items, then dropdown the listbox (using the arrow button for example) and select the third item and press ENTER, the listbox disappear and now the combobox has the focus. If you press the Down Key (VK_DOWN) the fourth item would be selected but....
if you previously set up a KeyDown Event for this combobox, it wont get called! some way the underlaying gtkwidget is handling this before the LCL control, If it is possible, I would like to get this events first in order to allow or deny the item selection.
There are two cases when this works normally: when the Itemindex:=0 And the
pressed key is [UP] and when Itemindex:=Items.Count-1 And the pressed key is
[DOWN], reading the gtk reference it appears that this is so by design as I
asked before: http://www.lazarus.freepascal.org/archives/msg02335.htmlThe goal I'm seeking here is to allow UP/DOWN keys ONLY IF the listbox is poped up and let grid's selection move IF NOT.
What I want is to have Combobox editors in a grid (mainly with option goAlwaysShowEditor) in such way that moving between cells with ComboBox Editors will not trap the keyboard focus (and doing unwished item selections!) I want free key navigating instead.
ugly. But do note, that when you set csdropdownlist and maybe autodropdown
(though I am not sure what is the purpose of autodropdown, "Mattias can
you explain what is the purpose of autodropdown?") the listbox should automatically
show up when you press any key without the need to press ALT+DOWN .
As for the above explanation, I need a way to show the combobox listbox using the keyboard, apart from F2 I was thinking on CTRL+DOWN?. I have not checked other options apart from the default, I will check csDropDownList to see if that fit the intended behaviour.
Perhaps what I want its easier to do in some other way, suggestions?
Thanks & Regards.
Jesus Reyes A.
Hi Jesus,
Regarding your question whether it is possible to have a milti-column listbox, well it is possible. If you have time reading the gtk reference, you will find that the list of items that can be displayed by the GtkCombo can be any item that is PGtkItem, or was it PgtkWidget???? So basically, you can pack any controls you want into the list for GtkCombo? But I am not sure if we can put some headers and footers. Maybe it is better to implement it ourselves not relying onto GtkCombo list property.
BTW, any updates on your TDBGrid unit. It seems to have a problem with current version of lazarus. I have tried it at home, it gives some AV on DC brushes or something like that.
Regards,
Yoyong