B4J Code Snippet Tweak the HTMLEditor toolbars AFTER loading a modal

Crock

Member
Licensed User
Somebody might find this workaround handy.

I needed to edit some HTML text with a few basic commands (bold, underline etc) with the HTMLEditor in a modal window on top of the main form. I can simplify the HTMLEditor's toolbar by hiding the top row and all the ComboBoxes in the lower one with custom routines (not shown below).

It makes sense that the HTMLEditor must be displayed before you can change its toolbar elements but ShowAndWait prevents us from auto-executing code after it shows the modal form. Luckily, in my case, it seems that the HTMLEditor_Resize event is fired when it displays and we can call the toolbar changes from there. Do let me know if there is a simpler or better way to do this.

Code in the MainForm:
B4X:
Sub btnReviseTopic_Click
   Dim frmModal As Form     
   frmModal.Initialize("",-1,-1)
   frmModal.RootPane.LoadLayout("layReviseTopic")
   HTMLEditor1.HtmlText = txtTopic.Text
   'No good calling the toolbar hacks here
   frmModal.ShowAndWait
   'code here gets called after the modal form closes
End Sub

Sub HTMLEditor1_Resize (Width As Double, Height As Double)
   'This event happens AFTER ShowAndWait
   SetToolbar(HTMLEditor1,0,False) 'hides the top (0) toolbar
   HideToolbarCombos(HTMLEditor1,1) 'hide Paragraph, Font etc on lower toolbar (1)
End Sub
 
Top