DrawControlInLayoutEditor when in a streched webcontainer?

I use this event to draw my websdk in the window editor
problem: if the websdk is inside a webcontainer, and some locks are in place, the rectangle is drawn with the size of the original websdk and not the streched one
how can I get the height and width of the streched websdk here in place of g.height and g.width ?
thanks.

Sub DrawControlInLayoutEditor(g As Graphics) Handles DrawControlInLayoutEditor
  Dim mVisible As String = StringProperty("Visible")
  If mVisible<>"true" Then
    g.Transparency = 70
    g.DrawingColor = &c00000000
    g.DrawRoundRectangle 0,0,g.Width,g.Height,5,5
    g.DrawLine 0,0,g.Width,g.Height
    g.DrawLine 0,g.Height,g.Width,0
    Return
  End If
  
  g.DrawingColor = &c00000000
  
  // But if the Enabled property is turned off...
  If Not BooleanProperty("Enabled") Then
    g.Transparency = 70
  Else
    g.Transparency = 0
  End If
  
  // draw the button caption depending on the size and outline
  g.FontSize = 16
  g.Italic = True
  Dim mName As String = StringProperty("Name")
  g.DrawText(mName, 10, 20)
  
  g.DrawRoundRectangle 0,0,g.Width,g.Height,5,5
  
End Sub

My guess is that this is a bug that Xojo needs to fix. Again, this is only a guess.
The ā€˜stretch’ works directly on the WebPage but not inside the container (for IDE representation only). On the Browser it works correctly.

IDE:
screencast2025-04-1711AM-01-14-ezgif.com-resize

Browser:
screencast2025-04-1711AM-09-22-ezgif.com-resize

Maybe @Ricardo_Cruz can confirm if he can do something to make the IDE work correctly or if there is need for extra code.

Edit: sample project
TestWebSDKContainer.xojo_binary_project.zip (15.4 KB)

1 Like

@Jean-Yves_Pochez

Are you talking about the layout editor of the container itself? Or are you talking about the drawing of a container instance on a web page?

I’m talking of the IDE layout editor. running on the web page the size is the right one.

this is the container control containing the websdk (carousel)

this is the webcontainer streched inside a dialog:

Ok, so what that means is that the container contents are not being recalculated when it’s on a layout.

Now, try putting a WebButton inside that container, locked left and right. Does it change size when you resize the container?

Not sure if you can see my messages. I did this on the GIF above.

Green Untitled is a WebSDK button.
Blue OK is a WebButton.

1 Like

Right and that’s what I was getting at (sorry Alberto, I’m typing faster than reading).

IIRC, we (when I worked at Xojo) found that redrawing each container’s contents was very processor intensive and slowed things way down if you had more than two or three containers on a page.

They may have optimized things since then, so we’d need @Ricardo_Cruz to chime in here.

2 Likes

I’m away until Monday, I’ll properly check this then, but it looks like the cache invalidation might not be working in that specific scenario.

If that’s the case, maybe it isn’t even specific to the Web SDK drawing event, it probably affects other controls.

Could you please create a new Issue in the meantime?

2 Likes

I remember trying to fix this bug at one point. Hopefully you’ll have better luck than I did.

done
https://tracker.xojo.com/xojoinc/xojo/-/issues/78967

2 Likes

I did not see this happen elsewhere but the websdkuicontrols

2 Likes

Just keep in mind that drawing each websdk control involves running a xojoscript. We translated the entire Graphics object into a context object (plus a few things you needed to access properties and constants), an escape mechanism (so drawing these could not lock up the IDE with an endless loop), add your drawing script and then run it to create a picture that the IDE can use. With precompiled scripts that should be very fast, but there’s still going to be some overhead.

1 Like