lwake@runcible.West.Sun.COM (Larry Wake) (12/07/90)
In article <353@shuksan.UUCP> scott@shuksan.UUCP (Scott Moody) writes: >Major Annoyance: > Openlook took away the list item CYCLE where you could click the cycle > icon and the menu choices would cycle through. Now clicking will > get you the FIRST item. To get to any others you MUST use the menu, > adding annoying steps! Not exactly right: clicking gets you the DEFAULT item, which is *initialized* to the first item on the list; however, the default can be changed at any time, either by the user (with CONTROL-SELECT) or by the application itself (hmm...). This distinction gives you a way to do what you want to do. I've heard this request/complaint enough times from enough people (including myself :-) that I thought I'd post my solution: 1. Make sure your application knows how many choices are in your choice item. A good place to store this is as the choice item's PANEL_CLIENT_DATA (or XV_KEY_DATA). 2. When you initialize your choice item, set its PANEL_DEFAULT_VALUE to the second item on your list (that is, 1). 3. Include the following code fragment in the choice item's notify proc: top_choice = (int)xv_get(item, PANEL_CLIENT_DATA); xv_set(item, PANEL_DEFAULT_VALUE, (value < top_choice) ? value + 1 : 0, NULL); Voila: PANEL_CYCLE! A variation of this would be to make the first choice in the stack be "(Next)", and track the "real" current value of the item manually. Now steps two and three would be the following: 2. When you initialize the item, set PANEL_VALUE to the first "real" item on your list, which is 1 (leave PANEL_DEFAULT_VALUE as 0). Also initialize a static variable called "myval" to 1 (or attach it to the item as XV_KEY_DATA); we'll use it to track the current value of the list. 3. Include this fragment in your notify proc: if (value == 0) { myval = (myval < top_choice) ? myval + 1 : 1; xv_set(item, PANEL_VALUE, myval, NULL); } else myval = value; This might be closer to OPEN LOOK compliance, as it still allows the user to pick their own default selection, which the first example will instead keep automagically changing on them. (PS: Note that the "OPEN LOOK Graphical User Interface Application Style Guidelines" book has an example of a "Cycle Menu Button" on pp. 271-2, so it's not fair to say that the OPEN LOOK GUI "took away" the idea of a cycle. It's there; it's just that XView doesn't [yet] have all the pieces to allow you to do it exactly the way they propose.) (PPS: get and read the above-mentioned book if you haven't already; it's chock full of great hints for application design, and shows just how much thought went into the OPEN LOOK GUI.) -- Larry Wake, Sun Microsystems (larry.wake@west.sun.com)