Dynamic WebButton: MemberSet's Bug?

The desktop method of dynamically creating a button using a member-set does not work on web as it does in desktop.

Dim newButton as WebButton
newButton = New MyButton

newButton.Top = 50
newButton.Left = 50

fails.

I’ve implemented a custom control that can do it, and even include styles

http://www.xojodevspot.com/demos/dynamicbutton.xojo_binary_project

but before I completely re-invent “the wheel,” I’d like to know what the standard practice for dynamically creating a WebButton would be.

(The demo contains the dynamic control interface I built for a quiz application and a very simple “Propagate” and “Clear” implementation.)

Figured it out… wrong search keywords :slight_smile:

Dim newButton as WebButton
newButton = AddMyButton

newButton.Top = 50
newButton.Left = 50

Wish the methods could be consistent across desktop and web though.

I don’t think many people use the “AddMyButton” style, I think most use the more explicit EmbedWithin method…

[code]dim newButton as new WebButton

newButton.Top = 50
newButton.Left = 50

newButton.EmbedWithin(self, newButton.Left, newButton.Top, newButton.Width, newButton.Height)
[/code]
The first param is the view to embed the control into, hence self or me if code is running in the scope of a WebPage or WebContainer.

The way I have always one it is to create a custom control containing the button etc and then dynamically create and position the control on the page. Their is a webinar where Paul explains the multiple ways you can do this.

[quote=110915:@Ian Jones]I don’t think many people use the “AddMyButton” style, I think most use the more explicit EmbedWithin method…

[code]dim newButton as new WebButton

newButton.Top = 50
newButton.Left = 50

newButton.EmbedWithin(self, newButton.Left, newButton.Top, newButton.Width, newButton.Height)
[/code]
The first param is the view to embed the control into, hence self or me if code is running in the scope of a WebPage or WebContainer.[/quote]
Agreed - I’ve done quite a bit of this including control arrays, etc. Has worked very well for me.

AHA! I have found 2 troublesome bugs in the web edition framework which doesn’t allow controls in membersets to propertly access their names and or properties through Introspection (this includes looping through the controls by ControlAtIndex). All dynamically created elements of a memberset retain the name of their “Parent” control. All non-memberset controls do not work in their manor, nor do any non-memberset and memberset desktop controls.

Here’s two identical projects (desktop and web) that display the Web Edition MemberSet bug.

Desktop:
http://www.xojodevspot.com/demos/desktopversion.xojo_binary_project

Web:
http://www.xojodevspot.com/demos/xojowemembersetbug.xojo_binary_project

Here’s the Screenshot of the apps side-by-side:

For this project, looping through each control will drastically effect the performance of the application and is very inefficient, so this bug is a “show-stopper” until it gets fixed. :-/ Not to mention the second bug which effects both Desktop and Web Edition (see picture).

Controlset arrays are improperly numbered and offset by 3…

Where

For i as integer = 0 to ControlCount -1 Listbox1.AddRow Control(i).Name next

should be used to list all controls on the window,

For i as integer = 0 to ControlCount + 2 Listbox1.AddRow Control(i).Name next

must be used to actually grab all control names.

feedback://showreport?report_id=34469