WebToolBar.Enabled Property Doesn't Do Anything

Setting the WebToolBar.Enabled property to False doesn’t disable the toolbar.

If it’s only actual WebToolBarItem objects which are meant to be disabled, it probably make sense to remove the WebToolBar.Enabled property?

Otherwise WebToolBar.Enabled should block the toolbar from being clicked and change its visual state when it’s set to False.

See case https://tracker.xojo.com/xojoinc/xojo/-/issues/77724

Extends method to work around the issue below.

Public Sub enabled_WORKAROUND(extends wtb as WebToolbar, assigns is_enabled as Boolean)
  if wtb.LastItemIndex < 0 then Return
  
  for n as integer = 0 to wtb.LastItemIndex
    wtb.ItemAt(n).Enabled = is_enabled
    
  next
  
  Return
End Sub

Notes:

  • If you are using this method in a library module shared across multiple project types, you should adjust each methods attributes so they’re only included in Web Projects:

  • This method enables or disables all toolbar items as a proxy for enabling/disabling the entire toolbar. It won’t remember the “state” of individual items’ .Enabled property, so if you need a mix of enabled/disabled buttons, you’ll need to handle this yourself. (and you probably don’t need this method? :thinking: )

fyi @Ricardo_Cruz

What about this?

webtoolbar-enable.xojo_binary_project.zip (8.7 KB)

It uses some CSS to grayscale the toolbar and ignore any pointer event, so the children enabled property won’t need to be modified.

2 Likes

@Ricardo_Cruz - thanks! I’ll take a look after I have my lunch.

1 Like

@Ricardo_Cruz I already looked and I wouldn’t use your option. Here’s why:

Looking at the attached screenshots below.

Hopefully you’ll see why I feel disabling the buttons more accurately conveys (visually) to the user that the toolbar is disabled.


(using my extends method which disables every item)

vs.


(CSS method you shared)

I think the first image (where all of the buttons have been disabled via the Extends method I shared above) is much more effective in conveying the toolbar being disabled. No?

Now I’m really going to have my lunch. :yum:

Yeah, I also think it looks better when individual items are disabled. I’ll have to implement it in the JavaScript side to make it work that way.

In the meantime, setting pointer-events to none with CSS will also prevent the user to click on the Title.

Enjoy your lunch!

1 Like

@Ricardo_Cruz Thanks! Have a good evening. :smile:

1 Like