📄 combobox.man
字号:
See XXmmTTeexxttFFiieellddGGeettSSeelleeccttiioonnPPoossiittiioonn. cchhaarr **XXmmCCoommbbooBBooxxGGeettSSttrriinngg((WWiiddggeett ww)) See XXmmTTeexxttFFiieellddGGeettSSttrriinngg. vvooiidd XXmmCCoommbbooBBooxxIInnsseerrtt((WWiiddggeett ww,, XXmmTTeexxttPPoossiittiioonn ppoossiittiioonn,, cchhaarr **vvaalluuee)) See XXmmTTeexxttFFiieellddIInnsseerrtt. BBoooolleeaann XXmmCCoommbbooBBooxxPPaassttee((WWiiddggeett ww)) See XXmmTTeexxttFFiieellddPPaassttee. BBoooolleeaann XXmmCCoommbbooBBooxxRReemmoovvee((WWiiddggeett ww)) See XXmmTTeexxttFFiieellddRReemmoovvee. vvooiidd XXmmCCoommbbooBBooxxRReeppllaaccee((WWiiddggeett ww,, XXmmTTeexxttPPoossiittiioonn ffrroomm__ppooss,, XXmmTTeexxttPPoossiittiioonn ttoo__ppooss,, cchhaarr **vvaalluuee)) See XXmmTTeexxttFFiieellddRReeppllaaccee. vvooiidd XXmmCCoommbbooBBooxxSSeettAAddddMMooddee((WWiiddggeett ww,, BBoooolleeaann ssttaattee)) See XXmmTTeexxttFFiieellddSSeettAAddddMMooddee. vvooiidd XXmmCCoommbbooBBooxxSSeettHHiigghhlliigghhtt((WWiiddggeett ww,, XXmmTTeexxttPPoossiittiioonn lleefftt,, XXmmTTeexxttPPoossiittiioonn rriigghhtt,, XXmmHHiigghhlliigghhttMMooddee mmooddee)) See XXmmTTeexxttFFiieellddSSeettHHiigghhlliigghhtt. vvooiidd XXmmCCoommbbooBBooxxSSeettIInnsseerrttiioonnPPoossiittiioonn((WWiiddggeett ww,, XXmmTTeexxttPPoossiittiioonn ppoossiittiioonn)) See XXmmTTeexxttFFiieellddSSeettIInnsseerrttiioonnPPoossiittiioonn. vvooiidd XXmmCCoommbbooBBooxxSSeettMMaaxxLLeennggtthh((WWiiddggeett ww,, iinntt mmaaxx__lleennggtthh)) See XXmmTTeexxttFFiieellddSSeettMMaaxxLLeennggtthh.Version 1.31 20 March 1995 17XmComboBox(3Xm) Harry's Motif Tools XmComboBox(3Xm) vvooiidd XXmmCCoommbbooBBooxxSSeettSSeelleeccttiioonn((WWiiddggeett ww,, XXmmTTeexxttPPoossiittiioonn ffiirrsstt,, XXmmTTeexxttPPoossiittiioonn llaasstt,, TTiimmee ttiimmee)) See XXmmTTeexxttFFiieellddSSeettSSeelleeccttiioonn. vvooiidd XXmmCCoommbbooBBooxxSSeettSSttrriinngg((WWiiddggeett ww,, cchhaarr **vvaalluuee)) At least Motif 1.1 contains a very anoying bug. If you try to set the contents of an XmTextField to an empty string (""), you'll get garbage, when asking the XmTextField for its contents afterwards. This interface function provides a work around. Also see XXmmTTeexxttFFiieellddSSeettSSttrriinngg. vvooiidd XXmmCCoommbbooBBooxxSShhoowwPPoossiittiioonn((WWiiddggeett ww,, XXmmTTeexxttPPoossiittiioonn ppoossii-- ttiioonn)) See XXmmTTeexxttFFiieellddSShhoowwPPoossiittiioonn. TThhee DDiisslliikkeedd KKeeyybbooaarrdd FFooccuuss Now I'll annotate a somewhat tricky subject. If the resource XXmmNNppeerrssiisstteennttDDrrooppDDoowwnn defaults to its initial value of FFaallssee, one can observe the following effect (this may be annoying). When the user drops down the list and then moves the mouse cursor out of the window where the combo box resides in, the list will be hidden. This is because the widget lost the keyboard focus. Some users are irritated because they didn't expect that behavior, because they just moved the mouse to get it out of the way. If your window manager's focus policy is "pointer focus", i.e. if you move the pointer into another window, that window will automati- cally get the keyboard focus. On the other hand, if your window manager's focus policy is "explicit", you have to move the pointer into another window and click a mouse button to give that window the keyboard focus. This is often referred to as the "click-to-type" method. In "explicit" mode, you will never see the list's annoying behavior. To bypass this behavior on some window managers a really dirty hack was used. The user can activate that hack, if he sets XXmmNNppeerrssiisstteennttDDrrooppDDoowwnn to TTrruuee in the application's resources. Sorry, on some window managers this will not fix the annoying behavior. Try it if you like - but don't complain at me if it doesn't work as expected. But at least it worked on the author's machine: a cute little SGI Indigo running 4dwm as the window manager. On some other window managers like twm you will face another problem: the list gets hidden as soon as the mouseVersion 1.31 20 March 1995 18XmComboBox(3Xm) Harry's Motif Tools XmComboBox(3Xm) cursor enters the list. Try to set XXmmNNttwwmmHHaannddlliinnggOOnn to TTrruuee. This resource will also work with other window man- agers. CCrreeaattiinngg aa CCoommbbooBBooxx Using the combo box in your own programs is easy. Just create the widget with one of the innumerable X toolkit functions (like XXttCCrreeaatteeMMaannaaggeeddWWiiddggeett or XXttVVaaCCrreeaatteeMMaann-- aaggeeddWWiiddggeett). Specify as the widget class xmComboBoxWidgetClass - that's all. There is also a so-called creation convenience func- tion called XXmmCCrreeaatteeCCoommbbooBBooxx, but it isn't really needed. WWiiddggeett XXmmCCrreeaatteeCCoommbbooBBooxx((_p_a_r_e_n_t_, _n_a_m_e_, _a_r_g_l_i_s_t_, _a_r_g_c_o_u_n_t)) WWiiddggeett _p_a_r_e_n_t; SSttrriinngg _n_a_m_e; AArrggLLiisstt _a_r_g_l_i_s_t; CCaarrddiinnaall _a_r_g_c_o_u_n_t; Somewhere in your program you'll need something like the following code fragment: Widget ComboBox; ComboBox = XtVaCreateManagedWidget("combobox", xmComboBoxWidgetClass, Parent, XmNeditable, True or False, other Resources... NULL); Setting the resource XXmmNNeeddiittaabbllee is not absolutely neces- sary, but it's better to do so. After creation, items can be added to the combo box's list by means of interface functions like XXmmCCoommbbooBBooxxAAdd-- ddIItteemm((......)). Which item the user selected can be deter- mined by calling XXmmCCoommbbooBBooxxGGeettSSttrriinngg((......)). If you want to preselect an item (that is setting a default item to the input field of the combo box) you can use several convenience functions. On a combo box with a non editable input field there are two ways to select an item: XmComboBoxSelectPos(ComboBox, item #, False); or:Version 1.31 20 March 1995 19XmComboBox(3Xm) Harry's Motif Tools XmComboBox(3Xm) XmComboBoxSelectItem(ComboBox, itemString, False); The third parameter in these two function calls indicates whether the XXmmNNsseelleeccttiioonnCCaallllbbaacckk should be called. The only difference between these functions is the first one is expecting an item number whereas the second one expects a XmString. The list is then searched for this string and if it is found the input field will be updated. On a combo box with XXmmNNeeddiittaabbllee set to TTrruuee use another function: XmComboBoxSetString(ComboBox, string); This sets the contents of the text input field to string.BBUUGGSS Not more than currently available in Motif 1.2.3 or Motif 1.2.4, but less than in the upcomming Motif 2.0. Report bugs to albrecht@igpm.rwth-aachen.de. Include a thoroughly description, and say which version of the ComboBox widget you are using.CCOOPPYYRRIIGGHHTT Copyright 1993, 1994 Harald Albrecht. The ComboBox widget is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Founda- tion; either version 2, or (at your option) any later ver- sion.AAVVAAIILLAABBIILLIITTYY The most recent released version of the ComboBox widget is always available for anonymous ftp from either ftp.x.org (198.112.44.100) /contrib/widgets/motif/ComboBox or from ftp.informatik.rwth-aachen.de (137.226.112.172) /pub/packages/ComboBoxAAUUTTHHOORR Author of Software & Documentation:Version 1.31 20 March 1995 20XmComboBox(3Xm) Harry's Motif Tools XmComboBox(3Xm) Harald Albrecht Institut fuer Geometrie und Praktische Mathematik RWTH Aachen, Bundesrepublik Deutschland e-mail: albrecht@igpm.rwth-aachen.de English Documentation: Chris Marotz Sterling Software ITD e-mail: marotz@itd.sterling.comRREELLAATTEEDD IINNFFOORRMMAATTIIOONN
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -