home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!pipex!bnr.co.uk!uknet!lsl!snail
- From: snail@lsl.co.uk
- Newsgroups: comp.windows.x
- Subject: Re: Help with XmCreateScrolledText
- Message-ID: <1993Jan11.181327.2918@lsl.co.uk>
- Date: 11 Jan 93 18:13:27 GMT
- References: <1993Jan8.213117.12635@b8.b8.ingr.com>
- Organization: Laser-Scan Ltd., Cambridge
- Lines: 47
-
- In article <1993Jan8.213117.12635@b8.b8.ingr.com>, paries@b8.b8.ingr.com (Randy Paries) writes:
- > My problem is that I can't seem to stop/force the user
- > to 60 chars lines.
- >
- > My Goal is at 60 chars to either ring a bell so that they
- > have to hit <CR> or even better have it wrap.
- >
- > At present with the resources above I can make the TextWidget
- > apprear with 60 columns and not change widths, but they can
- > continue to Type for ever.
-
- Okay, right first thing, do what you want with your resources, it'll make not
- a lot of difference, really.
-
- You need to add an XmNmodifyVerifyCallback to your text widget.
-
- static XtCallbackProc callback_func(Widget w,
- XtPointer client_data,
- XmTextVerifyCallbackStruct str)
- This callback
- can then check the length of the existing text and incoming text and decide
- wether it should break the incoming text up, or disallow the incoming text.
- A delete is detected by looking for inserted text of length zero, the
- str->text->ptr and str->text->length fields of the callback structure will be
- NULL and zero. You can in general ignore the str->text->format field.
-
- For instance you can set the str->doit field to FALSE if the text is too long
- (remember that deleting from one line across a \n may cause a line to be too
- long). If you set the XmNverifyBell resource to TRUE, the bell will
- automatically sound if the user tries to do something which results in you
- setting str->doit to false.
-
- See the XmText man page.
-
- This works, I've done similar stuff this way. You could also implement enough
- stuff to remember how to do an undo/redo function, although I haven't had the
- need to do this yet.
-
- You can also use XmNvalueChangedCallback, except this gets called after the
- event. I wouldn't recommend this.
- --
- snail@lsl.co.uk
-
- "Washing one's hands of the conflict between the powerful and the powerless
- means to side with the powerful, not to be Neutral."
- Quote by Freire.
- Poster by OXFAM.
-