Live feedback from a MultilineEditText gui?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/06/2012 at 11:53, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   12 
    Platform:      
    Language(s) :     C++  ;

    ---------
    Is there a way to get live feedback from a MultilineEditText gui?

    Bool myDialog::CreateLayout(void)  
    {  
      
      GroupBegin(0,BFH_LEFT,2,0,"MyTextGroup",0);  
      {                  
          AddEditText(1001, BFH_SCALEFIT,400,15,0);            //A single line text box gui  
          AddMultiLineEditText(1002, BFH_SCALEFIT,400,150,0);  //A multi line textbox gui  
      }  
      GroupEnd();  
      
      return TRUE;  
    }  
      
      
      
    Bool myDialog::Command(LONG id,const BaseContainer &msg)  
    {  
      
      String textbox;  this->GetString (1001, textbox);  
      GePrint(textbox);   //This prints live while typing text into the gui--->Yay!!  
      
      
      String multi_textbox;  this->GetString (1002, multi_textbox);  
      GePrint(multi_textbox); // <--- This does NOT print live while typing like the textbox gui  
                              //      It only prints when the user selects another part of the dialog.  Boo!! :-(  
      
      
      
      return TRUE;  
    }
    

    -ScottA



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 22/06/2012 at 06:14, xxxxxxxx wrote:

    I think you must catch the text entry in the Message() method.   I would think it works the same as a regular EditText for which you should find some examples here maybe but I'm having trouble finding them or any that I may have tried in the past.  If I find some code then will post it asap. :)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 22/06/2012 at 07:08, xxxxxxxx wrote:

    Hi,

    You can overload Message() and capture BFM_GETCURSORINFO message:

    virtual LONG Message(const BaseContainer &msg,BaseContainer &result)
    {
        GePrint("Message()");
        GePrint(LongToString(msg.GetId()));
      
        if (msg.GetId()==BFM_GETCURSORINFO)
        {
            String text;
            if(GetString(1002, text))
                GePrint(text);
        }
      
        return GeDialog::Message(msg,result);
    }
    

    BFM_GETCURSORINFO wasn't designed for this but it's the only message sent when text is typed inside the MultilineEditText.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 22/06/2012 at 08:53, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    BFM_GETCURSORINFO wasn't designed for this but it's the only message sent when text is typed inside the MultilineEditText.

    OK. Thanks.
    Like you said. While the cursor is inside of a multilineEditText box. It's sort of being quarantined.
    So It doesn't respond to messages like keyboard key presses.
    Example :

    LONG myDialog::Message(const BaseContainer &msg, BaseContainer &result)  
    {  
      switch(msg.GetId())  
       {  
      
         case BFM_INPUT:   //A dialog/userarea receives this message if any mouse or keyboard input is received  
      
            if(msg.GetLong(BFM_INPUT_DEVICE) == BFM_INPUT_KEYBOARD) //If the input is from the keyboard  
             {  
               String input = msg.GetString(BFM_INPUT_ASC);   //Create a string type variable...   
               GePrint(input);                                //and assign it to the pressed key's unicode-text value  
               if(input == ".")   
               {  
                 GePrint("period key was pressed");  
               }  
             }  
            break;  
      
       }  
      return GeDialog::Message(msg,result);  
    }
    

    Can I just request that the developers put better text wrangling within the MLTE(and maybe the other gui's) on their radar screens?
    I don't know how many people are using this text editing stuff in their plugins. But better MLTE integration is something I would probably use often.

    If you have meetings with the devs. Please tell the developer that made these two little message functions (GETCURSORPOS & SETCURSORPOS) that it was worth the time and effort to make them.
    I use them often.

    Thanks,
    -ScottA



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 22/06/2012 at 13:11, xxxxxxxx wrote:

    I just noticed the forum supports YouTube videos. That's cool!
    Here's a video showing what I'm doing with the Multi text box gui:fibU-B-yzK4

    This is the code I used to make it:

    LONG myDialog::Message(const BaseContainer &msg, BaseContainer &result)  
    {  
      String allWords;            //This will hold the entire text in the textbox  
      GetString(1001,allWords);    
      
      String lastWord;            //This will hold the last word that is typed into a text box  
      
      if (msg.GetId()==BFM_GETCURSORINFO)  
      {  
          String text;  
          if(GetString(1001, text))  
          {  
              LONG length = text.GetLength();  
              LONG pos = NULL;                                 //The variable that will hold the postion of the string  
              Bool lastSpace = text.FindLast(" ",&pos, -1);    //Find the last blank space and store it's position in the string  
              if(pos>0)                                        //If there is at least one empty space found  
              {  
                String lw = text.SubStr(pos+1, length - pos);  //Grab the last word (sub string)  
                lastWord = lw;  
              }  
          }  
      }      
      
      if (lastWord == "doc.")  
      {  
         String popupText;  
         LONG editX, editY, editW, editH;                          //Create variables to position the popup GUI  
              if(GetItemDim(1028, &editX, &editY, &editW, &editH)) //Queries a dialog control for its current size and position in pixels  
               {  
                 if(Local2Screen(&editX, &editY))  
                  {  
                    BaseContainer entries;                        //Create a container to store the popup entries  
                    entries.SetString(FIRST_POPUP_ID+0, "GetActiveDocument()");  
                    entries.SetString(FIRST_POPUP_ID+1, "SetActiveDocument(BaseDocument* doc)");   
                    entries.SetString(FIRST_POPUP_ID+2, "LoadDocument(const Filename& name, SCENEFILTER loadflags, BaseThread* thread)");  
                    //Add more entries as needed  
                                
                    LONG mypopup = ShowPopupMenu(NULL, editX, editY+(editH+300), entries); //Creates & positions the popup GUI  
                    if(mypopup!=NULL)  
                     {  
                      popupText += entries.GetString(mypopup);     //Increment(step/loop) through each popup entry and get each value  
                      SetString(1001, allWords + popupText);       //Adds the user selected popup text into the textbox                      
                     }  
                  }  
                }  
      }  
        
      return GeDialog::Message(msg,result);  
    }
    

    I was able to write this in R12.
    I'm still a learner, and the code is probably not very good. But there's already just enough text handling code in the SDK's to at least create this kind of thing in a basic form. Even from a relative newbie like me.
    But anything the developers can think of to make writing this kind of thing easier and more robust would be very cool.

    -ScottA


Log in to reply