wjhagins@VUSE.VANDERBILT.EDU (William J. Hagins) (06/24/89)
I have several asciiStringWidgets managed by a formWidget, and I want a loop to refresh the widgets (i.e., reset the strings to nulls). I have tried the resets offered in the Athena Widget docs, and I have tried to assign each string to a variable name, and then assigning the variable string to null. None of this has worked. Can anyone offer a solution to this problem. Thanks, -Jody. wjhagins@vuse.vanderbilt.edu
converse@EXPO.LCS.MIT.EDU (Donna Converse) (06/26/89)
> I have > tried the resets offered in the Athena Widget docs, These are not useful for widgets of asciiStringWidgetClass. > and I have tried to > assign each string to a variable name, and then assigning the variable > string to null. If I understand you correctly: Don't re-assign the address of the string. Think of the address of the string as specifying a buffer. To reset the string displayed by the buffer, set the first character in the buffer to the null character. The asciiStringWidget uses the buffer in-place; if you loose the address of the buffer, you loose control over what it contains. Donna Converse converse@expo.lcs.mit.edu
kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (06/27/89)
[ William Hagins writes: ] > > and I have tried to > > assign each string to a variable name, and then assigning the variable > > string to null. [ Donna Converse writes: ] > If I understand you correctly: > Don't re-assign the address of the string. Think of the address of the > string as specifying a buffer. To reset the string displayed by the > nbuffer, set the first character in the buffer to the null character. > The asciiStringWidget uses the buffer in-place; if you loose the address > of the buffer, you loose control over what it contains. A bit more information on this one: The string resource should be treated as a READ ONLY buffer. There are only two acceptable methods of changing the string in a text widget from inside an application. 1) With an editable text widget you may use XtTextReplace(). You can modify the text widget's translations to make an editable text widget be unmodifiable by the user. 2) You may also destroy the StringSource and create a new StringSource. This will give you a new string. Since the text widget maintains internal state, changing the string out from underneath it may cause strange and unpredictable results. Chris D. Peterson MIT X Consortium Net: kit@expo.lcs.mit.edu Phone: (617) 253 - 9608 Address: MIT - Room NE43-213
swick@ATHENA.MIT.EDU (Ralph R. Swick) (06/29/89)
Date: Fri, 23 Jun 89 12:31:54 CDT From: wjhagins@vuse.vanderbilt.edu (William J. Hagins) I have several asciiStringWidgets managed by a formWidget, and I want a loop to refresh the widgets (i.e., reset the strings to nulls). ... Can anyone offer a solution to this problem. Do this: { XtTextBlock text; XtTextPosition last; text.ptr = NULL; text.firstPos = 0; text.length = 0; text.format = FMT8BIT; last = number_of_characters_in_current_string; if (XtTextReplace(w, 0, last, &text)) { /* an error occurred */ } } If you don't know the size of the current string, here's a hack to retrieve it, given the limitations of the R3 AsciiString widget: { XtTextPosition last; XtTextSetInsertionPoint(w, 9999999); last = XtTextGetInsertionPoint(w); }
kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (06/29/89)
> Can anyone offer a solution > to this problem. [ Ralph writes: ] > Do this: > { > XtTextBlock text; > XtTextPosition last; > > text.ptr = NULL; > text.firstPos = 0; > text.length = 0; > text.format = FMT8BIT; > > last = number_of_characters_in_current_string; > > if (XtTextReplace(w, 0, last, &text)) { > /* an error occurred */ > } >} 1) This will only work on EDITABLE Text Widgets, this will always return an error if the Text Widget is read only. 2) The last function call should be. if (XtTextReplace(w, 0, last, &text) != XawEditDone) { /* an error occurred */ } There is no guarantee that XawEditDone is zero, it just happens to be that way in the current implementation. For further information on this function consult the Athena Widget Documentation (pp 26). Chris D. Peterson MIT X Consortium Net: kit@expo.lcs.mit.edu Phone: (617) 253 - 9608 Address: MIT - Room NE43-213