1<?xml version="1.0" encoding="UTF-8" ?> 2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"> 3 4<chapter id='Pop_Up_Widgets'> 5<title>Pop-Up Widgets</title> 6<para> 7Pop-up widgets are used to create windows outside of the 8window hierarchy defined by the widget tree. 9Each pop-up child has a window that is a descendant of the root window, 10so that the pop-up window is not clipped by the pop-up widget's parent window. 11Therefore, pop-ups are created and attached differently to their widget parent 12than normal widget children. 13</para> 14 15<para> 16A parent of a pop-up widget does not actively manage its pop-up children; 17in fact, it usually does not operate upon them in any way. 18The <emphasis remap='I'>popup_list</emphasis> field in the 19<function>CorePart</function> 20structure contains the list of its pop-up children. 21This pop-up list exists mainly to provide the proper place in the widget 22hierarchy for the pop-up to get resources and to provide a place for 23<xref linkend='XtDestroyWidget' xrefstyle='select: title'/> 24to look for all extant children. 25</para> 26 27<para> 28A 29composite 30widget can have both normal and pop-up children. 31A pop-up can be popped up from almost anywhere, not just by its parent. 32The term <emphasis remap='I'>child</emphasis> always refers to a normal, geometry-managed widget 33on the composite widget's list of children, and the term 34<emphasis remap='I'>pop-up child</emphasis> always refers to a 35widget on the pop-up list. 36</para> 37 38<sect1 id="Pop_Up_Widget_Types"> 39<title>Pop-Up Widget Types</title> 40<para> 41There are three kinds of pop-up widgets: 42</para> 43 44<itemizedlist spacing='compact'> 45 <listitem> 46 <para> 47Modeless pop-ups 48 </para> 49 <para> 50A modeless pop-up (for example, a dialog box that does not prevent 51continued interaction with the rest of the application) 52can usually be manipulated by the window manager 53and looks like any other application window from the 54user's point of view. 55The application main window itself is a special case of a modeless pop-up. 56 </para> 57 </listitem> 58 <listitem> 59 <para> 60Modal pop-ups 61 </para> 62 <para> 63A modal pop-up (for example, a dialog box that requires user input to 64continue) 65can sometimes be manipulated by the window manager, 66and except for events that occur in the dialog box, 67it disables user-event distribution to the rest of the application. 68 </para> 69 </listitem> 70 <listitem> 71 <para> 72Spring-loaded pop-ups 73 </para> 74 <para> 75A spring-loaded pop-up (for example, a menu) 76can seldom be manipulated by the window manager, 77and except for events that occur in the pop-up or its descendants, 78it disables user-event distribution to all other applications. 79 </para> 80 </listitem> 81</itemizedlist> 82<para> 83Modal pop-ups and spring-loaded pop-ups are very similar and should be coded as 84if they were the same. 85In fact, the same widget (for example, a ButtonBox or Menu widget) can be used both 86as a modal pop-up and as a spring-loaded pop-up within the same application. 87The main difference is that spring-loaded pop-ups are brought up 88with the pointer and, because of the grab that the pointer button causes, 89require different processing by the Intrinsics. 90Furthermore, all user input remap events occurring outside the spring-loaded 91pop-up (e.g., in a descendant) are also delivered to the spring-loaded 92pop-up after they have been dispatched to the appropriate descendant, so 93that, for example, button-up can take down a spring-loaded pop-up no 94matter where the 95button-up occurs. 96</para> 97 98<para> 99Any kind of pop-up, in turn, can pop up other widgets. 100Modal and spring-loaded pop-ups can constrain user events to 101the most recent such pop-up or allow user events to be dispatched 102to any of the modal or spring-loaded pop-ups 103currently mapped. 104</para> 105 106<para> 107Regardless of their type, 108all pop-up widget classes are responsible for communicating with the 109X window manager and therefore are subclasses of 110one of the 111Shell 112widget classes. 113</para> 114</sect1> 115 116<sect1 id="Creating_a_Pop_Up_Shell"> 117<title>Creating a Pop-Up Shell</title> 118<para> 119For a widget to be popped up, 120it must be the child of a pop-up shell widget. 121None of the Intrinsics-supplied shells will 122simultaneously manage more than one child. 123Both the shell and child taken together are referred to as the pop-up. 124When you need to use a pop-up, 125you always refer to the pop-up by the pop-up shell, 126not the child. 127</para> 128 129<para> 130To create a pop-up shell, use 131<xref linkend='XtCreatePopupShell' xrefstyle='select: title'/>. 132</para> 133 134<funcsynopsis id='XtCreatePopupShell'> 135<funcprototype> 136<funcdef>Widget <function>XtCreatePopupShell</function></funcdef> 137 <paramdef>const char * <parameter>name</parameter></paramdef> 138 <paramdef>WidgetClass <parameter>widget_class</parameter></paramdef> 139 <paramdef>Widget <parameter>parent</parameter></paramdef> 140 <paramdef>ArgList <parameter>args</parameter></paramdef> 141 <paramdef>Cardinal <parameter>num_args</parameter></paramdef> 142</funcprototype> 143</funcsynopsis> 144 145<variablelist> 146 <varlistentry> 147 <term> 148 <emphasis remap='I'>name</emphasis> 149 </term> 150 <listitem> 151 <para> 152Specifies the instance name for the created shell widget. 153 </para> 154 </listitem> 155 </varlistentry> 156 <varlistentry> 157 <term> 158 <emphasis remap='I'>widget_class</emphasis> 159 </term> 160 <listitem> 161 <para> 162Specifies the widget class pointer for the created shell widget. 163 </para> 164 </listitem> 165 </varlistentry> 166 <varlistentry> 167 <term> 168 <emphasis remap='I'>parent</emphasis> 169 </term> 170 <listitem> 171 <para> 172Specifies the parent widget. Must be of class Core or any subclass thereof. 173 </para> 174 </listitem> 175 </varlistentry> 176 <varlistentry> 177 <term> 178 <emphasis remap='I'>args</emphasis> 179 </term> 180 <listitem> 181 <para> 182Specifies the argument list to override any other resource specifications. 183 </para> 184 </listitem> 185 </varlistentry> 186 <varlistentry> 187 <term> 188 <emphasis remap='I'>num_args</emphasis> 189 </term> 190 <listitem> 191 <para> 192Specifies the number of entries in the argument list. 193 </para> 194 </listitem> 195 </varlistentry> 196</variablelist> 197 198<para> 199The 200<xref linkend='XtCreatePopupShell' xrefstyle='select: title'/> 201function ensures that the specified class is a subclass of 202Shell 203and, rather than using insert_child to attach the widget to the parent's 204<emphasis remap='I'>children</emphasis> list, 205attaches the shell to the parent's <emphasis remap='I'>popup_list</emphasis> directly. 206</para> 207 208<para> 209The screen resource for this widget is determined by first scanning 210<emphasis remap='I'>args</emphasis> for the XtNscreen argument. If no XtNscreen argument is 211found, the resource database associated with the parent's screen 212is queried for the resource <emphasis remap='I'>name</emphasis>.screen, class 213<emphasis remap='I'>Class</emphasis>.Screen where <emphasis remap='I'>Class</emphasis> is the <emphasis remap='I'>class_name</emphasis> 214field from the 215<function>CoreClassPart</function> 216of the specified <emphasis remap='I'>widget_class</emphasis>. 217If this query fails, the parent's screen is used. 218Once the screen is determined, 219the resource database associated with that screen is used to retrieve 220all remaining resources for the widget not specified in 221<emphasis remap='I'>args</emphasis>. 222</para> 223 224<para> 225A spring-loaded pop-up invoked from a translation table via 226<xref linkend='XtMenuPopup' xrefstyle='select: title'/> 227must already exist 228at the time that the translation is invoked, 229so the translation manager can find the shell by name. 230Pop-ups invoked in other ways can be created when 231the pop-up actually is needed. 232This delayed creation of the shell is particularly useful when you pop up 233an unspecified number of pop-ups. 234You can look to see if an appropriate unused shell (that is, not 235currently popped up) exists and create a new shell if needed. 236</para> 237 238<para> 239To create a pop-up shell using varargs lists, use 240<xref linkend='XtVaCreatePopupShell' xrefstyle='select: title'/>. 241</para> 242 243<funcsynopsis id='XtVaCreatePopupShell'> 244<funcprototype> 245<funcdef>Widget <function>XtVaCreatePopupShell</function></funcdef> 246 <paramdef>const char * <parameter>name</parameter></paramdef> 247 <paramdef>WidgetClass <parameter>widget_class</parameter></paramdef> 248 <paramdef>Widget <parameter>parent</parameter></paramdef> 249 <paramdef><parameter>...</parameter></paramdef> 250</funcprototype> 251</funcsynopsis> 252 253<variablelist> 254 <varlistentry> 255 <term> 256 <emphasis remap='I'>name</emphasis> 257 </term> 258 <listitem> 259 <para> 260Specifies the instance name for the created shell widget. 261 </para> 262 </listitem> 263 </varlistentry> 264 <varlistentry> 265 <term> 266 <emphasis remap='I'>widget_class</emphasis> 267 </term> 268 <listitem> 269 <para> 270Specifies the widget class pointer for the created shell widget. 271 </para> 272 </listitem> 273 </varlistentry> 274 <varlistentry> 275 <term> 276 <emphasis remap='I'>parent</emphasis> 277 </term> 278 <listitem> 279 <para> 280Specifies the parent widget. Must be of class Core or any subclass thereof. 281 </para> 282 </listitem> 283 </varlistentry> 284 <varlistentry> 285 <term>...</term> 286 <listitem> 287 <para> 288Specifies the variable argument list to override any other 289resource specifications. 290 </para> 291 </listitem> 292 </varlistentry> 293</variablelist> 294 295 296<para> 297<xref linkend='XtVaCreatePopupShell' xrefstyle='select: title'/> 298is identical in function to 299<xref linkend='XtCreatePopupShell' xrefstyle='select: title'/> 300with <emphasis remap='I'>the</emphasis> args and <emphasis remap='I'>num_args</emphasis> parameters replaced by a varargs list as 301described in Section 2.5.1. 302</para> 303</sect1> 304 305<sect1 id="Creating_Pop_Up_Children"> 306<title>Creating Pop-Up Children</title> 307<para> 308Once a pop-up shell is created, 309the single child of the pop-up shell can be created 310either statically or dynamically. 311</para> 312 313<para> 314At startup, 315an application can create the child of the pop-up shell, 316which is appropriate for pop-up children composed of a fixed set 317of widgets. 318The application can change the state of the subparts of 319the pop-up child as the application state changes. 320For example, if an application creates a static menu, 321it can call 322<xref linkend='XtSetSensitive' xrefstyle='select: title'/> 323(or, in general, 324<xref linkend='XtSetValues' xrefstyle='select: title'/>) 325on any of the buttons that make up the menu. 326Creating the pop-up child early means that pop-up time is minimized, 327especially if the application calls 328<xref linkend='XtRealizeWidget' xrefstyle='select: title'/> 329on the pop-up shell at startup. 330When the menu is needed, 331all the widgets that make up the menu already exist and need only be mapped. 332The menu should pop up as quickly as the X server can respond. 333</para> 334 335<para> 336Alternatively, 337an application can postpone the creation of the child until it is needed, 338which minimizes application startup time and allows the pop-up child to 339reconfigure itself each time it is popped up. 340In this case, 341the pop-up child creation routine might poll the application 342to find out if it should change the sensitivity of any of its subparts. 343</para> 344 345<para> 346Pop-up child creation does not map the pop-up, 347even if you create the child and call 348<xref linkend='XtRealizeWidget' xrefstyle='select: title'/> 349on the pop-up shell. 350</para> 351 352<para> 353All shells have pop-up and pop-down callbacks, 354which provide the opportunity either to make last-minute changes to a 355pop-up child before it is popped up or to change it after it is popped down. 356Note that excessive use of pop-up callbacks can make 357popping up occur more slowly. 358</para> 359</sect1> 360 361<sect1 id="Mapping_a_Pop_Up_Widget"> 362<title>Mapping a Pop-Up Widget</title> 363<para> 364Pop-ups can be popped up through several mechanisms: 365</para> 366<itemizedlist spacing='compact'> 367 <listitem> 368 <para> 369A call to 370<xref linkend='XtPopup' xrefstyle='select: title'/> 371or 372<xref linkend='XtPopupSpringLoaded' xrefstyle='select: title'/>. 373 </para> 374 </listitem> 375 <listitem> 376 <para> 377One of the supplied callback procedures 378<xref linkend='XtCallbackNone' xrefstyle='select: title'/>, 379<xref linkend='XtCallbackNonexclusive' xrefstyle='select: title'/>, 380or 381<xref linkend='XtCallbackExclusive' xrefstyle='select: title'/>. 382 </para> 383 </listitem> 384 <listitem> 385 <para> 386The standard translation action 387<xref linkend='XtMenuPopup' xrefstyle='select: title'/>. 388 </para> 389 </listitem> 390</itemizedlist> 391 392<para> 393Some of these routines take an argument of type 394<function>XtGrabKind</function>, 395which is defined as 396</para> 397<programlisting> 398typedef enum {XtGrabNone, XtGrabNonexclusive, XtGrabExclusive} XtGrabKind; 399</programlisting> 400 401<para> 402The create_popup_child_proc procedure pointer 403in the shell widget instance record is of type 404<xref linkend='XtCreatePopupChildProc' xrefstyle='select: title'/>. 405</para> 406 407<funcsynopsis id='XtCreatePopupChildProc'> 408<funcprototype> 409<funcdef>typedef void *<function>XtCreatePopupChildProc</function></funcdef> 410 <paramdef>Widget <parameter>w</parameter></paramdef> 411</funcprototype> 412</funcsynopsis> 413 414<variablelist> 415 <varlistentry> 416 <term> 417 <emphasis remap='I'>w</emphasis> 418 </term> 419 <listitem> 420 <para> 421Specifies the shell widget being popped up. 422 </para> 423 </listitem> 424 </varlistentry> 425</variablelist> 426 427 428<para> 429To map a pop-up from within an application, use 430<xref linkend='XtPopup' xrefstyle='select: title'/>. 431</para> 432 433<funcsynopsis id='XtPopup'> 434<funcprototype> 435<funcdef>void <function>XtPopup</function></funcdef> 436 <paramdef>Widget <parameter>popup_shell</parameter></paramdef> 437 <paramdef>XtGrabKind <parameter>grab_kind</parameter></paramdef> 438</funcprototype> 439</funcsynopsis> 440 441<variablelist> 442 <varlistentry> 443 <term> 444 <emphasis remap='I'>popup_shell</emphasis> 445 </term> 446 <listitem> 447 <para> 448Specifies the shell widget. 449 </para> 450 </listitem> 451 </varlistentry> 452 <varlistentry> 453 <term> 454 <emphasis remap='I'>grab_kind</emphasis> 455 </term> 456 <listitem> 457 <para> 458Specifies the way in which user events should be constrained. 459 </para> 460 </listitem> 461 </varlistentry> 462</variablelist> 463 464<para> 465The 466<xref linkend='XtPopup' xrefstyle='select: title'/> 467function performs the following: 468</para> 469<itemizedlist spacing='compact'> 470 <listitem> 471 <para> 472Calls 473<xref linkend='XtCheckSubclass' xrefstyle='select: title'/> 474to ensure <emphasis remap='I'>popup_shell</emphasis>'s class is a subclass of 475<function>shellWidgetClass</function>. 476 </para> 477 </listitem> 478 <listitem> 479 <para> 480Raises the window and returns if the shell's <emphasis remap='I'>popped_up</emphasis> field is already 481<function>True</function>. 482 </para> 483 </listitem> 484 <listitem> 485 <para> 486Calls the callback procedures on the shell's <emphasis remap='I'>popup_callback</emphasis> list, 487specifying a pointer to the value of <emphasis remap='I'>grab_kind</emphasis> as the <emphasis remap='I'>call_data</emphasis> 488argument. 489 </para> 490 </listitem> 491 <listitem> 492 <para> 493Sets the shell <emphasis remap='I'>popped_up</emphasis> field to 494<function>True</function>, 495the shell <emphasis remap='I'>spring_loaded</emphasis> field to 496<function>False</function>, 497and the shell <emphasis remap='I'>grab_kind</emphasis> field from <emphasis remap='I'>grab_kind</emphasis>. 498 </para> 499 </listitem> 500 <listitem> 501 <para> 502If the shell's <emphasis remap='I'>create_popup_child_proc</emphasis> field is non-NULL, 503<xref linkend='XtPopup' xrefstyle='select: title'/> 504calls it with <emphasis remap='I'>popup_shell</emphasis> as the parameter. 505 </para> 506 </listitem> 507 <listitem> 508 <para> 509If <emphasis remap='I'>grab_kind</emphasis> is either 510<function>XtGrabNonexclusive</function> 511or 512<function>XtGrabExclusive</function>, 513it calls 514 </para> 515<programlisting> 516XtAddGrab(<emphasis remap='I'>popup_shell</emphasis>, (<emphasis remap='I'>grab_kind</emphasis> == XtGrabExclusive), False) 517</programlisting> 518 </listitem> 519 <listitem> 520 <para> 521Calls 522<xref linkend='XtRealizeWidget' xrefstyle='select: title'/> 523with <emphasis remap='I'>popup_shell</emphasis> specified. 524 </para> 525 </listitem> 526 <listitem> 527 <para> 528Calls 529<function>XMapRaised</function> 530with the window of <emphasis remap='I'>popup_shell</emphasis>. 531 </para> 532 </listitem> 533</itemizedlist> 534<para> 535To map a spring-loaded pop-up from within an application, use 536<xref linkend='XtPopupSpringLoaded' xrefstyle='select: title'/>. 537</para> 538 539<funcsynopsis id='XtPopupSpringLoaded'> 540<funcprototype> 541<funcdef>void <function>XtPopupSpringLoaded</function></funcdef> 542 <paramdef>Widget <parameter>popup_shell</parameter></paramdef> 543</funcprototype> 544</funcsynopsis> 545 546<variablelist> 547 <varlistentry> 548 <term> 549 <emphasis remap='I'>popup_shell</emphasis> 550 </term> 551 <listitem> 552 <para> 553Specifies the shell widget to be popped up. 554 </para> 555 </listitem> 556 </varlistentry> 557</variablelist> 558 559<para> 560The 561<xref linkend='XtPopupSpringLoaded' xrefstyle='select: title'/> 562function performs exactly as 563<xref linkend='XtPopup' xrefstyle='select: title'/> 564except that it sets the shell <emphasis remap='I'>spring_loaded</emphasis> field to 565<function>True</function> 566and always calls 567<xref linkend='XtAddGrab' xrefstyle='select: title'/> 568with <emphasis remap='I'>exclusive</emphasis> 569<function>True</function> 570and <emphasis remap='I'>spring-loaded</emphasis> 571<function>True</function>. 572</para> 573 574<para> 575To map a pop-up from a given widget's callback list, 576you also can register one of the 577<xref linkend='XtCallbackNone' xrefstyle='select: title'/>, 578<xref linkend='XtCallbackNonexclusive' xrefstyle='select: title'/>, 579or 580<xref linkend='XtCallbackExclusive' xrefstyle='select: title'/> 581convenience routines as callbacks, using the pop-up shell widget as the 582client data. 583</para> 584 585<funcsynopsis id='XtCallbackNone'> 586<funcprototype> 587<funcdef>void <function>XtCallbackNone</function></funcdef> 588 <paramdef>Widget <parameter>w</parameter></paramdef> 589 <paramdef>XtPointer <parameter>client_data</parameter></paramdef> 590 <paramdef>XtPointer <parameter>call_data</parameter></paramdef> 591</funcprototype> 592</funcsynopsis> 593 594<variablelist> 595 <varlistentry> 596 <term> 597 <emphasis remap='I'>w</emphasis> 598 </term> 599 <listitem> 600 <para> 601Specifies the widget. 602 </para> 603 </listitem> 604 </varlistentry> 605 <varlistentry> 606 <term> 607 <emphasis remap='I'>client_data</emphasis> 608 </term> 609 <listitem> 610 <para> 611Specifies the pop-up shell. 612 </para> 613 </listitem> 614 </varlistentry> 615 <varlistentry> 616 <term> 617 <emphasis remap='I'>call_data</emphasis> 618 </term> 619 <listitem> 620 <para> 621Specifies the callback data argument, 622which is not used by this procedure. 623 </para> 624 </listitem> 625 </varlistentry> 626</variablelist> 627 628 629<funcsynopsis id='XtCallbackNonexclusive'> 630<funcprototype> 631<funcdef>void <function>XtCallbackNonexclusive</function></funcdef> 632 <paramdef>Widget <parameter>w</parameter></paramdef> 633 <paramdef>XtPointer <parameter>client_data</parameter></paramdef> 634 <paramdef>XtPointer <parameter>call_data</parameter></paramdef> 635</funcprototype> 636</funcsynopsis> 637 638<variablelist> 639 <varlistentry> 640 <term> 641 <emphasis remap='I'>w</emphasis> 642 </term> 643 <listitem> 644 <para> 645Specifies the widget. 646 </para> 647 </listitem> 648 </varlistentry> 649 <varlistentry> 650 <term> 651 <emphasis remap='I'>client_data</emphasis> 652 </term> 653 <listitem> 654 <para> 655Specifies the pop-up shell. 656 </para> 657 </listitem> 658 </varlistentry> 659 <varlistentry> 660 <term> 661 <emphasis remap='I'>call_data</emphasis> 662 </term> 663 <listitem> 664 <para> 665Specifies the callback data argument, 666which is not used by this procedure. 667 </para> 668 </listitem> 669 </varlistentry> 670</variablelist> 671 672 673<funcsynopsis id='XtCallbackExclusive'> 674<funcprototype> 675<funcdef>void <function>XtCallbackExclusive</function></funcdef> 676 <paramdef>Widget <parameter>w</parameter></paramdef> 677 <paramdef>XtPointer <parameter>client_data</parameter></paramdef> 678 <paramdef>XtPointer <parameter>call_data</parameter></paramdef> 679</funcprototype> 680</funcsynopsis> 681 682<variablelist> 683 <varlistentry> 684 <term> 685 <emphasis remap='I'>w</emphasis> 686 </term> 687 <listitem> 688 <para> 689Specifies the widget. 690 </para> 691 </listitem> 692 </varlistentry> 693 <varlistentry> 694 <term> 695 <emphasis remap='I'>client_data</emphasis> 696 </term> 697 <listitem> 698 <para> 699Specifies the pop-up shell. 700 </para> 701 </listitem> 702 </varlistentry> 703 <varlistentry> 704 <term> 705 <emphasis remap='I'>call_data</emphasis> 706 </term> 707 <listitem> 708 <para> 709Specifies the callback data argument, 710which is not used by this procedure. 711 </para> 712 </listitem> 713 </varlistentry> 714</variablelist> 715 716<para> 717The 718<xref linkend='XtCallbackNone' xrefstyle='select: title'/>, 719<xref linkend='XtCallbackNonexclusive' xrefstyle='select: title'/>, 720and 721<xref linkend='XtCallbackExclusive' xrefstyle='select: title'/> 722functions call 723<xref linkend='XtPopup' xrefstyle='select: title'/> 724with the shell specified by the <emphasis remap='I'>client_data</emphasis> argument 725and <emphasis remap='I'>grab_kind</emphasis> set as the name specifies. 726<xref linkend='XtCallbackNone' xrefstyle='select: title'/>, 727<xref linkend='XtCallbackNonexclusive' xrefstyle='select: title'/>, 728and 729<xref linkend='XtCallbackExclusive' xrefstyle='select: title'/> 730specify 731<function>XtGrabNone</function>, 732<function>XtGrabNonexclusive</function>, 733and 734<function>XtGrabExclusive</function>, 735respectively. 736Each function then sets the widget that executed the callback list 737to be insensitive by calling 738<xref linkend='XtSetSensitive' xrefstyle='select: title'/>. 739Using these functions in callbacks is not required. 740In particular, 741an application must provide customized code for 742callbacks that create pop-up shells dynamically or that must do more than 743desensitizing the button. 744</para> 745 746<para> 747Within a translation table, 748to pop up a menu when a key or pointer button is pressed or when the pointer 749is moved into a widget, use 750<xref linkend='XtMenuPopup' xrefstyle='select: title'/>, 751or its synonym, 752<function>MenuPopup</function>. 753From a translation writer's point of view, 754the definition for this translation action is 755</para> 756 757<funcsynopsis id='XtMenuPopup'> 758<funcprototype> 759<funcdef>void <function>XtMenuPopup</function></funcdef> 760 <paramdef>String <parameter>shell_name</parameter></paramdef> 761</funcprototype> 762</funcsynopsis> 763 764<variablelist> 765 <varlistentry> 766 <term> 767 <emphasis remap='I'>shell_name</emphasis> 768 </term> 769 <listitem> 770 <para> 771Specifies the name of the shell widget to pop up. 772 </para> 773 </listitem> 774 </varlistentry> 775</variablelist> 776 777<para> 778<xref linkend='XtMenuPopup' xrefstyle='select: title'/> 779is known to the translation manager, 780which registers the corresponding built-in action procedure 781<function>XtMenuPopupAction</function> 782using 783<xref linkend='XtRegisterGrabAction' xrefstyle='select: title'/> 784specifying <emphasis remap='I'>owner_events</emphasis> 785<function>True</function>, 786<emphasis remap='I'>event_mask</emphasis> 787<function>ButtonPressMask</function> 788<function>|</function> 789<function>ButtonReleaseMask</function>, 790and <emphasis remap='I'>pointer_mode</emphasis> and <emphasis remap='I'>keyboard_mode</emphasis> 791<function>GrabModeAsync</function>. 792</para> 793 794<para> 795If 796<xref linkend='XtMenuPopup' xrefstyle='select: title'/> 797is invoked on 798<function>ButtonPress</function>, 799it calls 800<xref linkend='XtPopupSpringLoaded' xrefstyle='select: title'/> 801on the specified shell widget. 802If 803<xref linkend='XtMenuPopup' xrefstyle='select: title'/> 804is invoked on 805<function>KeyPress</function> 806or 807<function>EnterWindow</function>, 808it calls 809<xref linkend='XtPopup' xrefstyle='select: title'/> 810on the specified shell widget with <emphasis remap='I'>grab_kind</emphasis> set to 811<function>XtGrabNonexclusive</function>. 812Otherwise, the translation manager generates a 813warning message and ignores the action. 814</para> 815 816<para> 817<xref linkend='XtMenuPopup' xrefstyle='select: title'/> 818tries to find the shell by searching the widget tree starting at 819the widget in which it is invoked. 820If it finds a shell with the specified name in the pop-up children of 821that widget, it pops up the shell with the appropriate parameters. 822Otherwise, it moves up the parent chain to find a pop-up child with the 823specified name. 824If 825<xref linkend='XtMenuPopup' xrefstyle='select: title'/> 826gets to the application top-level shell widget and has not 827found a matching shell, it generates a warning and returns immediately. 828</para> 829</sect1> 830 831<sect1 id="Unmapping_a_Pop_Up_Widget"> 832<title>Unmapping a Pop-Up Widget</title> 833<para> 834Pop-ups can be popped down through several mechanisms: 835</para> 836<itemizedlist spacing='compact'> 837 <listitem> 838 <para> 839A call to 840<xref linkend='XtPopdown' xrefstyle='select: title'/> 841 </para> 842 </listitem> 843 <listitem> 844 <para> 845The supplied callback procedure 846<xref linkend='XtCallbackPopdown' xrefstyle='select: title'/> 847 </para> 848 </listitem> 849 <listitem> 850 <para> 851The standard translation action 852<xref linkend='XtMenuPopdown' xrefstyle='select: title'/> 853 </para> 854 </listitem> 855</itemizedlist> 856<para> 857To unmap a pop-up from within an application, use 858<xref linkend='XtPopdown' xrefstyle='select: title'/>. 859</para> 860 861<funcsynopsis id='XtPopdown'> 862<funcprototype> 863<funcdef>void <function>XtPopdown</function></funcdef> 864 <paramdef>Widget <parameter>popup_shell</parameter></paramdef> 865</funcprototype> 866</funcsynopsis> 867 868<variablelist> 869 <varlistentry> 870 <term> 871 <emphasis remap='I'>popup_shell</emphasis> 872 </term> 873 <listitem> 874 <para> 875Specifies the shell widget to pop down. 876 </para> 877 </listitem> 878 </varlistentry> 879</variablelist> 880 881<para> 882The 883<xref linkend='XtPopdown' xrefstyle='select: title'/> 884function performs the following: 885</para> 886<itemizedlist spacing='compact'> 887 <listitem> 888 <para> 889Calls 890<xref linkend='XtCheckSubclass' xrefstyle='select: title'/> 891to ensure <emphasis remap='I'>popup_shell</emphasis>'s class is a subclass of 892<function>shellWidgetClass</function>. 893 </para> 894 </listitem> 895 <listitem> 896 <para> 897Checks that the <emphasis remap='I'>popped_up</emphasis> field of <emphasis remap='I'>popup_shell</emphasis> is 898<function>True</function>; 899otherwise, it returns immediately. 900 </para> 901 </listitem> 902 <listitem> 903 <para> 904Unmaps <emphasis remap='I'>popup_shell</emphasis>'s window and, if <emphasis remap='I'>override_redirect</emphasis> is 905<function>False</function>, 906sends a synthetic 907<function>UnmapNotify</function> 908event as specified by the <emphasis remap='I'>Inter-Client Communication Conventions Manual</emphasis>. 909 </para> 910 </listitem> 911 <listitem> 912 <para> 913If <emphasis remap='I'>popup_shell</emphasis>'s <emphasis remap='I'>grab_kind</emphasis> is either 914<function>XtGrabNonexclusive</function> 915or 916<function>XtGrabExclusive</function>, 917it calls 918<xref linkend='XtRemoveGrab' xrefstyle='select: title'/>. 919 </para> 920 </listitem> 921 <listitem> 922 <para> 923Sets <emphasis remap='I'>popup_shell</emphasis>'s <emphasis remap='I'>popped_up</emphasis> field to 924<function>False</function>. 925 </para> 926 </listitem> 927 <listitem> 928 <para> 929Calls the callback procedures on the shell's <emphasis remap='I'>popdown_callback</emphasis> list, 930specifying a pointer to the value of the shell's <emphasis remap='I'>grab_kind</emphasis> field 931as the <emphasis remap='I'>call_data</emphasis> argument. 932 </para> 933 </listitem> 934</itemizedlist> 935<para> 936To pop down a pop-up from a callback list, you may use the callback 937<xref linkend='XtCallbackPopdown' xrefstyle='select: title'/>. 938</para> 939 940<funcsynopsis id='XtCallbackPopdown'> 941<funcprototype> 942<funcdef>void <function>XtCallbackPopdown</function></funcdef> 943 <paramdef>Widget <parameter>w</parameter></paramdef> 944 <paramdef>XtPointer <parameter>client_data</parameter></paramdef> 945 <paramdef>XtPointer <parameter>call_data</parameter></paramdef> 946</funcprototype> 947</funcsynopsis> 948 949<variablelist> 950 <varlistentry> 951 <term> 952 <emphasis remap='I'>w</emphasis> 953 </term> 954 <listitem> 955 <para> 956Specifies the widget. 957 </para> 958 </listitem> 959 </varlistentry> 960 <varlistentry> 961 <term> 962 <emphasis remap='I'>client_data</emphasis> 963 </term> 964 <listitem> 965 <para> 966Specifies a pointer to the 967<function>XtPopdownID</function> 968structure. 969 </para> 970 </listitem> 971 </varlistentry> 972 <varlistentry> 973 <term> 974 <emphasis remap='I'>call_data</emphasis> 975 </term> 976 <listitem> 977 <para> 978Specifies the callback data argument, 979which is not used by this procedure. 980 </para> 981 </listitem> 982 </varlistentry> 983</variablelist> 984 985<para> 986The 987<xref linkend='XtCallbackPopdown' xrefstyle='select: title'/> 988function casts the <emphasis remap='I'>client_data</emphasis> parameter to a pointer of type 989<function>XtPopdownID</function>. 990</para> 991<programlisting> 992typedef struct { 993 Widget shell_widget; 994 Widget enable_widget; 995} XtPopdownIDRec, *XtPopdownID; 996</programlisting> 997<para> 998The <emphasis remap='I'>shell_widget</emphasis> is the pop-up shell to pop down, 999and the <emphasis remap='I'>enable_widget</emphasis> is usually the widget that was used to pop it up 1000in one of the pop-up callback convenience procedures. 1001</para> 1002 1003<para> 1004<xref linkend='XtCallbackPopdown' xrefstyle='select: title'/> 1005calls 1006<xref linkend='XtPopdown' xrefstyle='select: title'/> 1007with the specified <emphasis remap='I'>shell_widget</emphasis> 1008and then calls 1009<xref linkend='XtSetSensitive' xrefstyle='select: title'/> 1010to resensitize <emphasis remap='I'>enable_widget</emphasis>. 1011</para> 1012 1013<para> 1014Within a translation table, 1015to pop down a spring-loaded menu when a key or pointer button is 1016released or when the 1017pointer is moved into a widget, use 1018<xref linkend='XtMenuPopdown' xrefstyle='select: title'/> 1019or its synonym, 1020<function>MenuPopdown</function>. 1021From a translation writer's point of view, 1022the definition for this translation action is 1023</para> 1024 1025<funcsynopsis id='XtMenuPopdown'> 1026<funcprototype> 1027<funcdef>void <function>XtMenuPopdown</function></funcdef> 1028 <paramdef>String <parameter>shell_name</parameter></paramdef> 1029</funcprototype> 1030</funcsynopsis> 1031 1032<variablelist> 1033 <varlistentry> 1034 <term> 1035 <emphasis remap='I'>shell_name</emphasis> 1036 </term> 1037 <listitem> 1038 <para> 1039Specifies the name of the shell widget to pop down. 1040 </para> 1041 </listitem> 1042 </varlistentry> 1043</variablelist> 1044 1045<para> 1046If a shell name is not given, 1047<xref linkend='XtMenuPopdown' xrefstyle='select: title'/> 1048calls 1049<xref linkend='XtPopdown' xrefstyle='select: title'/> 1050with the widget for which the translation is specified. 1051If <emphasis remap='I'>shell_name</emphasis> is specified in the translation table, 1052<xref linkend='XtMenuPopdown' xrefstyle='select: title'/> 1053tries to find the shell by looking up the widget tree starting at the 1054widget in which it is invoked. 1055If it finds a shell with the specified name in the pop-up children 1056of that widget, it pops down the shell; 1057otherwise, it moves up the parent chain to find a pop-up child with the 1058specified name. 1059If 1060<xref linkend='XtMenuPopdown' xrefstyle='select: title'/> 1061gets to the application top-level shell widget 1062and cannot find a matching shell, 1063it generates a warning and returns immediately. 1064</para> 1065</sect1> 1066</chapter> 1067