trailing space remove in value-changed event!!

yanfug

New Member
Hi everybody!

Does anyone knows why the trailing space type in a fill-in or browse column are remove from the screen-value when checking it in the value-changed of that fill-in?

if so, is it possible to change that behavior or test something else that have my trailing space in it ?


thanks
 
unfortunately this feature can't be turned off although if V6Display is YES the trailing spaces won't be removed. but V6Display influences on other stuff as well therefore it doesn't suit. you've got workarounds to keep the spaces though. First you can use SELECTION-TEXT attribute instead of SCREEN-VALUE (but you have to select fill-in before using it). Second you can add something (non-space) into the end of your fill-in value and trim it before using the value.

HTH
 
Well, thanks for the work around!

But what i really want to do is:

Simulate a combo-box style in browse column and if the user type in the text instead of selecting it for the selection list displayed over the browse when clicking on the button display over the browse cell.

I would like to do an incremental search when user type text and showing the coresponding value in the column with the end of the text highlighted.

here's the code (this is in a include file):


ON "VALUE-CHANGED":U OF {&Desc-Field} IN BROWSE {&Brws-Name} DO:
DEF VAR i# AS INT NO-UNDO.
DEF VAR TypeIn AS CHAR NO-UNDO.

/* Flag that value have change */
{&Value-Change} = TRUE.


IF SELF:SELECTION-START > 0 THEN
TypeIn = SUBSTRING(SELF:SCREEN-VALUE, 1, SELF:SELECTION-START - 1).

ELSE
TypeIn = SELF:SCREEN-VALUE.

/* search in selection list for matching entry */

DO i# = 1 TO {&Combo-Handle}:NUM-ITEMS * 2 BY 2:
IF ENTRY(i#, {&Combo-Handle}:LIST-ITEM-PAIRS) BEGINS TypeIn THEN
LEAVE.

END.


IF i# <= {&Combo-Handle}:NUM-ITEMS * 2 THEN DO:
ASSIGN {&Combo-Handle}:SCREEN-VALUE = ENTRY(i# + 1, {&Combo-Handle}:LIST-ITEM-PAIRS)
SELF:SCREEN-VALUE = ENTRY(i#, {&Combo-Handle}:LIST-ITEM-PAIRS).

SELF:SET-SELECTION( LENGTH(TypeIn) + 1, LENGTH(SELF:SCREEN-VALUE) + 1 ).

END.

ELSE
MESSAGE "No matching value found" VIEW-AS ALERT-BOX ERROR.


RETURN.

END.

hope that will help you understanding what i want to do!
 
Hi everyone! just posting the anwser!:)

/* Incremental search if user want to type in the value */



ON "VALUE-CHANGED":U OF {&Desc-Field} IN BROWSE {&Brws-Name} DO:
DEF VAR i# AS INT NO-UNDO.
DEF VAR TypeIn AS CHAR NO-UNDO.

/* Flag that value have change */
{&Value-Change} = TRUE.
TypeIn = SELF:SCREEN-VALUE.

/* if spacebar at the end, not included in screen-value */
IF LASTKEY = 32 THEN TypeIn = TypeIn + " ".

/* search in selection list for matching entry */


DO i# = 1 TO {&Combo-Handle}:NUM-ITEMS * 2 BY 2:
IF ENTRY(i#, {&Combo-Handle}:LIST-ITEM-PAIRS) BEGINS TypeIn THEN LEAVE.


END.



IF i# <= {&Combo-Handle}:NUM-ITEMS * 2 THEN DO:
ASSIGN {&Combo-Handle}:SCREEN-VALUE = ENTRY(i# + 1, {&Combo-Handle}:LIST-ITEM-PAIRS)
SELF:SCREEN-VALUE = ENTRY(i#, {&Combo-Handle}:LIST-ITEM-PAIRS)

/* assign value to field in browse */
{&Key-Field} = {&Combo-Handle}:SCREEN-VALUE.

SELF:SET-SELECTION( LENGTH(TypeIn) + 1, LENGTH(SELF:SCREEN-VALUE) + 1).


END.


ELSE DO:
MESSAGE "No matching value found" VIEW-AS ALERT-BOX ERROR.

APPLY "ENTRY":U TO SELF.

/* select only the last invalid character */
SELF:SET-SELECTION( LENGTH(TypeIn), LENGTH(TypeIn) + 1).


END.

RETURN.



END.
 
Back
Top