[comp.windows.x.motif] Desensitising item in List widget

E_CMA@vaxa.nerc-murchison.ac.uk (04/29/91)

>>I'm looking for a way to "de-sensitize" an item in a List widget.
>>I want the item to be greyed and unselectable.  Any suggestions would
>>be greatly appreciated.  Oh, by the way, we're running X11R4 with motif 1.0.

>However, you can probably fake it in your application with some difficulty.
>First, a list item is an XmString, so you can specify a different charset
>for the item than for other items in the list and then specify a font in
>the list's fontlist that matches the charset and gives you the visual you
>want.  The next problem is making the item unselectable.  One idea would be
>to have the application keep track of the insensitive items and the items
>currently selected.  Then you would set up a selection callback that when
>called would check the item selected against the list of insensitive items
>and if the selected item matched would deselect that item and reselect the
>previously selected items.  Otherwise it would just update the application's
>list of selected items.  The major drawback with this approach is that
>you'll get flashing whenever the list selects an item and your application
>immediately de-selects.  Unfortunately I can't think of a way around this
>without mucking with the list internals.

Until something better comes along...

If I may make a suggestion, perhaps a bit of lateral thinking is in order.
Try replacing the XmList widget with something along the lines of...

   XmScrolledWindow -> 

            XmRowColumn 
                {XmNorientation = Xm_VERTICAL;} ->

                 XmText widgets  with...
                 {XmNeditable = false;  ...for all items, allows selection
                  XmNsensitive = false:  and 
                  XmNforeground and/or XmNbackground and/or XmNfontList 
                    set to someting different for unselectable items  }; 

   Not quite the same fuctionality as the List widget, but for single
   select, using the XmNactivate callback should do nicely. It also has
   the advantages of the callback itself explicitly identifying the item
   selected and of being able to work in ordinary strings, which can be a 
   mite quicker than working in compound strings.      

  Cheers
     C.
*************************************************************************
* Snailmail:		    *  E_Mail	                                *
*			    *  CBS%UK.AC.NERC-MURCHISON.VAXA::E_CMA     *	
* Dr C.M.Allen		    *  JANET: e_cma@uk.ac.nmh.va                *
* British Geological Survey *                                           *
* Murchison House           * 	                                        *
* West Mains Road           *                                           * *************************************************************************
* Edinburgh                 * Tel: 031-667-1000 x277 from U.K.		*
* Scotland                  * 						*
* EH9,3LA                   * 						*
*************************************************************************