Submitted by Anonymous on Wed, 12/27/2000 - 18:31. Developers
Hi...
I`m not a big lesstif/motif fan but I need to write one lesstif
application for a computer lab and I need some help. In my
program I`m using "XmScrolledList" in the "Browse" mode.
I added a function for the callback "XmNbrowseSelectionCallback"
and it`s working fine when I`m using a mouse to click on items
in the list. The problems appears when I try to browse the list
using a keyboard - although pressing keys "ArrowUp", "PageUp",
(and so on) changes the selection, it does not call my callback
procedure. I don`t know what to do - when I press "Enter" it
calls "XmNdefaultSelectionCallback" procedure but when I press
"ArrowDown" it calls nothing. How can I fix it? I need it to make
my program work the way I want it to work.
please help
have u tried the space bar?
instead of enter.
Hmm...
Spacebar does nothing in the "browse" mode and Enter is not what I need. Enter is equal to DoubleClick action and arrow keys are equal to Click action. The problem is that pressing arrow keys doesn`t call any callback...
could u post u`r code.
just the scrolledlist parts. could be u`r coding.
meanwhile, this scrolled list works for me.
just wrote one up. works perfectly fine. space bar and enter work, along with up and down arrows.
check it out.
#include
#include
#include
#include
void listCB(Widget widget,XtPointer clientdata,XtPointer calldata)
{
XmListCallbackStruct *ptr;
char *string;
ptr = (XmListCallbackStruct *) calldata;
XmStringGetLtoR((ptr->item),XmSTRING_DEFAULT_CHARSET,&string);
printf("%s.
",string);
XtFree(string);
}
void AddToList(Widget widget,char *string)
{
XmString xmstring;
xmstring = XmStringCreateSimple(string);
XmListAddItemUnselected(widget,xmstring,0);
XmStringFree(xmstring);
}
int main(int argc,char **argv)
{
Widget parent,form,list,listparent;
XtAppContext app_context;
Arg args[10];
Cardinal n;
XmString xmstring;
n = 0;
parent = XtAppInitialize(&app_context, "Ppm", (XrmOptionDescList) NULL, 0,
&argc, argv, (String *) NULL, args, n);
XtSetArg(args[n],XmNheight,100); n++;
XtSetArg(args[n],XmNwidth,100); n++;
form = XmCreateForm(parent,"form",args,n);
n = 0;
XtSetArg(args[n],XmNselectionPolicy,XmBROWSE_SELECT); n++;
list = XmCreateScrolledList(form,"list",args,n);
listparent = XtParent(list);
XtManageChild(list);
XtVaSetValues(listparent,XmNtopAttachment,XmATTACH_FORM,
XmNleftAttachment,XmATTACH_FORM,
XmNbottomAttachment,XmATTACH_FORM,
XmNrightAttachment,XmATTACH_FORM,NULL);
AddToList(list,"one"); AddToList(list,"two"); AddToList(list,"three");
AddToList(list,"four");AddToList(list,"five");AddToList(list,"six");
XtAddCallback(list,XmNbrowseSelectionCallback,(XtCallbackProc) listCB,(XtPointer) NULL);
XtManageChild(form);
XtRealizeWidget(parent);
XtAppMainLoop(app_context);
return 0;
}
reporting bugs (Need help with ScrolledList
When posting to the Developer`s Forum, it would be a help if you specified which version of Motif you are using -- and, particularly, whether you`re using a version of LessTif. Then, it would both be easier for people to help you with the specific question and also to direct you to the correct email address or web site for reporting bugs you`ve found, if the problem does indeed turn out to be in the widget set or documentation.
My code is identical, except that ScrolledList is placed on BulletinBoard. The problem seems to be in Lesstif. I posted my problem to the newsgroups and here`s what I got from Alexander Mai (on comp.window.x.motif)
Looks like LessTif even as of 0.92.6 has a problem there.
I try to get it fixed. (an early attempt being in LessTif`s CVS,
but that may not be the final solution).
Actually the List widget of LessTif features some other glitches which
are currently being addressed - you`re welcome to report even more ... -)
i gues you`ll be using "forms" now, stelek?
time to uninstall my lesstif, and install open motif?