Jump to content

Change Form.NavigateKeys at runtime


lxpbuaa

Recommended Posts

At runtime,  change Form.NavigateKeys.Enabled or Form.NavigateKeys.Nex.Key,  it doesnt work.  

 

e.g.

 

procedure TEditDataForm.OnMemoEnter(Sender: TObject);
begin
  NavigateKeys.Next.Key := 0;
  NavigateKeys.Enabled := False;
end;
 
procedure TEditDataForm.OnMemoExit(Sender: TObject);
begin
  NavigateKeys.Next.Key := 13;
  NavigateKeys.Enabled := True;
end;
 
It means when the focus is in Memo editor, I can enter RETURN key as a line feed.
How can I do it?
Thanks!
 

 

Link to comment
Share on other sites

Hi,

 

It means when the focus is in Memo editor, I can enter RETURN key as a line feed.

How can I do it?

 

Maybe this will help you:

http://forums.unigui.com/index.php?/topic/6194-navigatekeys-unimemo/&do=findComment&comment=31702

 

UniMemo1 -> ClientEvents -> ExtEvents ... add keydown fn:

function keydown(sender, e, eOpts)
{
    if (e.getKey() == e.ENTER) {
        e.stopPropagation();
    }
}

Best regards.

Link to comment
Share on other sites

Hi,

 

 

Maybe this will help you:

http://forums.unigui.com/index.php?/topic/6194-navigatekeys-unimemo/&do=findComment&comment=31702

 

UniMemo1 -> ClientEvents -> ExtEvents ... add keydown fn:

function keydown(sender, e, eOpts)
{
    if (e.getKey() == e.ENTER) {
        e.stopPropagation();
    }
}

Best regards.

 

HI, I can't set the clienevent at runtime? Because the Memo editor is created dynamicly.

 

e.g.

  TUniMemo(Editor).ClientEvents.ExtEvents.Add
    ('keydown=function keydown(sender, e, eOpts) {if (e.getKey()== e.ENTER) {e.stopPropagation();}}');
Link to comment
Share on other sites

Oh, sorry ,unfortunately, the memo created at  runtime  doesnt work.

 

UniMemo1 is ok, but Memo doesnt work.  Can you help me?

 

procedure TMainForm.UniFormCreate(Sender: TObject);
const
  KeyDownText = 'function keydown(sender, e, eOpts) {if (e.getKey() == e.ENTER) {e.stopPropagation()}}';
var
  Memo: TUniMemo;
begin
  Memo := TUniMemo.Create(self);
  Memo.Parent := self;
  Memo.Left := 50;
  Memo.ClientEvents.ExtEvents.Values['keydown'] :=  KeyDownText;
  UniMemo1.ClientEvents.ExtEvents.Values['keydown'] :=  KeyDownText;
end;
 
Link to comment
Share on other sites

  • 1 year later...

Hi,

 

One possible solution:

 

UniMemo -> ClientEvents -> ExtEvents ->

function afterrender(sender, eOpts)
{
    sender.bodyEl.dom.addEventListener(
        'keydown', 
        function(e) {if (e.key=='Enter') {e.stopPropagation()}}
    );
}

Best regards,

Link to comment
Share on other sites

Hi,

 

Please use this approach for now:

 

Hi,

 

One possible solution:

 

UniMemo -> ClientEvents -> ExtEvents ->

function afterrender(sender, eOpts)
{
    sender.bodyEl.dom.addEventListener(
        'keydown', 
        function(e) {if (e.key=='Enter') {e.stopPropagation()}}
    );
}

Best regards,

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...