Jump to content

How to activate onKeyDown event on UniHTMLMemo component


Luis German

Recommended Posts

On 6/1/2023 at 6:03 PM, Luis German said:

To use Shift+enter in order to activate next control without using mouse

I was able to find one solution, but the main disadvantage is that you have to specify which control should receive focus.

Link to comment
Share on other sites

Solution:

1. UniHTMLMemo1.ClientEvents.ExtEvents ->

function initialize(sender, eOpts)
{
    sender.getDoc().addEventListener('keydown', function(e) {
        if (e.key == 'Enter' && e.shiftKey) {
            e.preventDefault();
            e.stopPropagation();
            ajaxRequest(sender, '_tab', {});
        }
    });
}

2. UniHTMLMemo1.OnAjaxEvent ->

procedure TMainForm.UniHTMLMemo1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName = '_tab' then
    UniButton1.WebFocus

end;

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...