Resize gizmo without redraw it [SOLVED]

On 12/04/2017 at 16:02, xxxxxxxx wrote:

Is it possible to change the size of a gizmo (actually a group) in a Gedialog without the need to flush it and recreate it.
Basicly my group is just one row of some editText set to SCALEFIT, so if I change the size of the group then logically all my edit text will be resized (which is exactly what I want).

A bit offtopic but just want let you know it's look like anchor for RadioGadget is wrong in the sdk. search (click into Flags or exemple in the search you will have an error 404)

Thanks in advance.

On 13/04/2017 at 09:22, xxxxxxxx wrote:

Hi gr4ph0s, thanks for writing us.

with reference to your question, I must admit I'm a bit confused, since standing from your sentence it's unclear if the resize of the group is made by your code or it occurs due to a user interaction. Definitively it is possibleto resize a group widget if the group is defined with BF*_SCALEFIT flags as much as the EditText widget and it's actually resized automatically when the user changes the size of the dialog hosting them but I have the feeling this is not the case you were asking about.
Can you reformulate in case?

With reference to the wrong anchor in the SDK thanks for spotting it and we'll take of it internally in order to have it fixed in a future release.

Best, Riccardo

On 13/04/2017 at 10:02, xxxxxxxx wrote:

Firstly thanks you for taking time to asnwerd.

What I want is someting like that where inputbox are sized automaticly when you write something.

And like in js you don't redraw everything you jsut set the size attribut of the gadget. I thinked about doing something similar in C4D if possible.
If not is there a message for the end of an editing? Because If I flush/redraw at each new character. The focus into the gadget is lost. So you have to re-click into the gadget for rewrite.Which is pretty boring.
So it's why a message for the ending editing would be nice.

If there is none I will go for a timer. But since python it's pretty slow I want to avoid as much as possible the use of timer.

On 14/04/2017 at 09:40, xxxxxxxx wrote:

Hi gr4ph0s, thanks for the additional explanation.

I've dig down a bit more to find that a message with ID 1648576083 is actually dispatched to the GeDialog instance everytime the value edited in EditText widget is "entered" by pressing Enter.
Unfortunately, on the other side, as you've already pointed out, there's no chance for a GeDialog to set the focus back to the last item having the focus before a layout is flushed and recreated (NOTE: for CustomGui there's a viable solution here).

If you can leave with this glitch and with the fact, differently from the JS example posted, the string box is resized only after pressing "Enter" then the snippet below might come in help.

  # the EditText widget has ID 1001  
  def Message(self, msg, result) :  
      # filter for the appropriate ID  
      if msg.GetId() == 1648576083:  
          # retrive the string value and the length  
          textvalue = self.GetString(1001)  
          textlength = len(textvalue)  
          # flush and recreate the layout with the appropriate size  
          self.AddEditText(1001, c4d.BFH_LEFT, textlength*10, 10)  
          # set back the value of the EditText widget  
          self.SetString(1001, textvalue)  
      return c4d.gui.GeDialog.Message(self, msg, result)

Best, Riccardo

On 14/04/2017 at 10:17, xxxxxxxx wrote:

Thanks I like this way. 
Does this id (1648576083) is safe to use?
And is there any compatibility version to it? Or it can be used in R15+ ?

Anyway thanks you.

On 18/04/2017 at 11:15, xxxxxxxx wrote:


I think Riccardo's posted code should be executed inside Command() for the edit text input events.
Then the following lines that activates the edit text and sets its cursor position should be added:

# Activates the edit text
# Builds the BFM_EDITFIELD_SETCURSORPOS message container
msg = c4d.BaseContainer()
msg.SetInt32(1, textlength) # Cursor position at data ID 1 inside the container
# Sends BFM_EDITFIELD_SETCURSORPOS to the edit text
self.SendMessage(1001, msg)