MATRIXx

cancel
Showing results for 
Search instead for 
Did you mean: 

uiText multiple line of text

I'm looking for some help using the uiText item.
From the help topics, I can easily add the item to a GUI for single lines of text.

If I make to small adjustments to the example code as follows:

Command ex_uitext {fragname, widgetname, instance}
Alias T "ex_uitext"
If (exist(fragname))
   GOTO *fragname;
Else
   void = uiToolCreate(T)
   MainWin = uiWindow(T, {name = "MainWin",
   title = "PGUI Text Example", type = "panel", visibility = 1,
      height = 250, width = 500, xr = 250, yr = 50})
   void = uiText(MainWin, {name = "TF", flags = "m",varname="text1",
      text = "Text Field", readonly = 0, xmath = "DoText",
      height = 80, width = 450, xr = 25, yr = 50})
   void = uiButton(MainWin, {type = "button", name = "PBE",
      text = "Exit", xmath = "DoExit",
      height = 30, width = 50, xr = 225, yr = 190})
   Return;
endIf
<DoText>
   display sprintf("Gui CB: MSC args are CB = %s, widget = %s, instance = %d",
      fragname, widgetname, instance);
   Return;
<DoExit>
   void = uiDestroy(T);
   Return;
endCommand

This open a GUI which allows me to enter multiple lines of code, however, I cannot get it to "return" or "accept" the updates. If I use the enter/return key it simply gives me a new line.

After entering 4 lines of text, how to I get it to return this and update the varname?

[running v7.1.5 on W2K]

Regards,
Brian
0 Kudos
Message 1 of 4
(7,925 Views)
Hi Brian,

If you add the flag "n" to the list of flags, then MatrixX will know when to execute the callback. This is tricky when using multiple line input, since Enter is  also used to go to the next line. So the callback will execute with each line entry. Therefore, it is probably best to implement a button rather than using Enter key, to avoid multiple callbacks.
 
Richard

Field Sales Engineer, New Jersey
National Instruments
0 Kudos
Message 2 of 4
(7,913 Views)

Richard,

As you mentioned this is tricky. An example would be much appreciated.

Concerns: If I add "n" to the list of flags in my example and re-run, everytime I press enter 2 things occur: 1- I get a new line in the uitext field. 2- I get an error message "***F*** A string may not span multiple lines; long strings may be composed with +." Even though "n" returns a call back the operation fails because the text spans multiple lines?

How do you propose to implement a button rather than using "Enter".

 

Brian

0 Kudos
Message 3 of 4
(7,905 Views)
Give this a try:

Command ex_uitextb {fragname, widgetname, instance}

Alias T "ex_uitextb"
 
    textout = ""
    textsum = ""

If (exist(fragname))
   GOTO *fragname;
Else
   void = uiToolCreate(T)
   MainWin = uiWindow(T, {name = "MainWin",
   title = "PGUI Text Example", type = "panel", visibility = 1,
      height = 250, width = 500, xr = 250, yr = 50})
   void = uiText(MainWin, {name = "TF", flags = "m,n",
      text = "Text Field", readonly = 0,
      height = 120, width = 450, xr = 25, yr = 50,xmath = "DoText"})
   void = uiButton(MainWin, {type = "button", name = "PBE",
      text = "Exit", xmath = "DoExit",
      height = 30, width = 50, xr = 225, yr = 190}) 
   Return;
endIf

<DoText>
   textout = uiGetValue(T,"TF",{value});
   display sprintf("Gui CB: MSC args are CB = %s, widget = %s, instance = %d text = %s",
      fragname, widgetname, instance, textout);
   Return;

<DoExit>
   void = uiDestroy(T);
   Return;

endCommand

If you need to delineate between one line and the next, I suggest appending a character of your choice to represent Newline,  and handling it as such in your own parsing functions.


Richard

Field Sales Engineer, New Jersey
National Instruments
0 Kudos
Message 4 of 4
(7,888 Views)