Issues with the TTMSFNCWXHTMLMemo component

We use TMS FNC WX Pack version 1.6.3.1.

  1. If we assign HTML formatted text to TTMSFNCWXHTMLMemo's HTML.Text property, carriage return/newlines are replaced by HTML br tags which we don't want in most cases. Would it be possible to extend this component with a new published boolean property ReplaceWithHTMLLineBreaks which is true by default for backwards compatibility but which we can set to false?
  2. In some scenarios, toolbar buttons which we set to invisible at design time are visible at runtime. We applied a fix which sets the toolbar's OnChanged event handler to nil in BeforeLoadDFMValues and restores/calls the toolbar's OnChanged event handler in AfterLoadDFMValues.
  3. Is there a way to control how an HTML paragraph tag is displayed in the memo, e.g. using CSS? We want the HTML p tags to be preserved but displayed just as an HTML br (newline) or with less vertical space.

Hi,

  1. Does this concern assigning the text at design-time? Because for programmatic assignment you can already achieve this by calling LoadHtmlContent(YourText, False).
  2. We could not reproduce this. Which framework are you using?
  3. Currently this is not supported for native platforms. We'd need to research the options for something like this. For WEB, the contents are actually rendered in the DOM so you can manipulate it with CSS. The "note-editable" class is added to the DIV that contains the HTML content. To modify the P paragraph element, you can simply:
    .note-editable p {
      margin-bottom: 0; /*remove bottom margin*/
    }
    
  1. No, it's ok for us to assign the text at run-time, so calling LoadHtmlContent with the False parameter should solve this issue.
  2. We use TMS Web Core.
  3. We already applied the kind of style you provided. So this issue is also solved.

Hi,

For 2 we applied an improvement. The next version will contain the necessary changes.

Ok. Point 2 of the original post is resolved in TMS FNC WX Pack version 1.7.0.0,
but there are two new issues:
4. Toolbar.Visible can't be switched at runtime.
5. If I enter the HTMLMemo, the OnEnter event handler is not triggered (the OnExit event handler is working).
With these issues, it is not possible to initially hide the toolbar and make it visible on entering the HTMLMemo.
We are still in the Web context using TMS Web Core version 2.6.1.2 and TMS FNC Core version 4.0.1.0.

I cannot reproduce that OnEnter is not triggered. See test project
Project3.zip (5.6 KB)

The project you sent us uses the TTMSFNCMemo component. We reported the OnEnter issue for the TTMSFNCWXHTMLMemo component.

Hi,

We tried investigating but it's unclear why this stopped working. The code executes but the summernote editor is not reinitialized anymore as it was before.

Specifically for WEB we implemented a fix that toggles the visibility of the toolbar separately whenever the editor is already initialized. This will be available with the next update.

Can you try the OnFocus event instead of OnEnter?

Ok, we see that with TMS FNC WX Pack 1.7.0.3 the Toolbar.Visible issue has been fixed. And yes, the OnFocus event is triggered when entering the component and thus can be used as an alternative to the OnEnter event.

But we found, that clicking a toolbar button, triggers the OnExit event and then the OnFocus event. If we would bind the Toolbar.Visible property to the OnFocus and OnExit events as we planned, we would recognize a flickering of the toolbar. Is there a way (e.g. by a new property) to check whether the Exit event was caused by clicking a toolbar button? I also remember the VCL RichEdit component to keep focus when a RichEdit toolbar button is pressed.

The OnFocus and OnExit are directly tied to the JavaScript onFocus and onBlur events of the summernote editor. We'll investigate if there's a way to prevent triggering them for toolbar interaction, stay tuned.

A new issue with Toolbar.Visible in 1.7.0.3 is, that if you set Toolbar.Visible to False at design time (in the .dfm file), the application throws the following runtime error:
TMSFNCWXHTMLMemo1_idToogleToolbar is not defined

We have already noticed this internally, and we are working on a fix for it.

Hi,

We applied improvements for both of these issues, the next version will contain the changes.

Keep in mind these events are just relaying the focus and blur events to application level, meaning an initial trigger will happen in WEB because the summernote library is forcing the focus onto the editor but another control from WEB Core can take this focus while the form is loading. You can assign the OnFocus and OnExit events later to prevent flickering.

We just installed TMS FNC WX Pack 1.7.1.0 and can now successfully toggle the toolbar's visibility.

1 Like

We found an issue in line 1098 of WEBLib.TMSFNCWXHTMLMemo:
ExecuteJavaScript(GetControlID + 'ToogleToolbar(false)');
should actually be
ExecuteJavaScript(GetControlID + 'ToggleToolbar(false)');

Thank you for notifying, we fixed it here. The next version will contain the correct "Toggle" instead of "Toogle", in the meantime feel free to replace the typo in your sources directly.

We have applied the fix to our sources.
We found yet another issue with the TMSFNCWXHTMLMemo component:
If you put a TMSFNCWXHTMLMemo component on a modal form and load text into the memo using LoadHtmlContent in the DOMContentLoaded event handler of the form, the TMSFNCWXHTMLMemo component is displayed with the assigned text, but neither property changes nor event handlers of the TMSFNCWXHTMLMemo component like OnFocus or OnExit are working. The reason is, that the TMSFNCWXHTMLMemo component is not yet initialized when calling LoadHtmlContent, that is TMSFNCWXHTMLMemo's DoHandleInit has not yet been called. So, how can we load text into the TMSFNCWXHTMLMemo component on startup of a modal form?
This issue does not occur, if the TMSFNCWXHTMLMemo component is put on the main form. There, the TMSFNCWXHTMLMemo component is first initialized and then the main form's DOMContentLoaded event handler is called.
We could provide a sample project, if you want.

This is somewhat expected, interacting with WX components during initialization will lead to breaks.
Is there something preventing you from using the OnInit event of the TTMSFNCWXHTMLMemo, which is triggered when the control is initialized and ready for interaction?

The TTMSFNCWXHTMLMemo's OnInit event actually solves this issue. Thank you. According to the IOC principle, I usually write a specific form routine that sets the values/texts of all fields on it. With FNC WX components, I will now write one OnInit event handler for all TTMSFNCWXHTMLMemo's on a form which checks whether all TTMSFNCWXHTMLMemo's have been initialized. If this is the case, the form routine to set the values/texts of all fields is called.

1 Like