Results 1 to 11 of 11

Thread: How do you do OnKeyDown

  1. #1
    Join Date
    Jan 2007
    Location
    Tennessee
    Posts
    642
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default How do you do OnKeyDown

    Form.OnkeyDown:= @KeyPress;

    For the procedure KeyPress what variables do you have to declare?
    And the same for OnKeyPress and OnKeyUp.
    I've never seen anyone use these.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    2,984
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    in scar > Tools > Event Handles list, voila
    Administrator's Warning:


  3. #3
    Join Date
    Nov 2006
    Posts
    1,103
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    or you could open a delphi compiler, the event parameters are exactly the same...
    Infractions, reputation, reflection, the dark side of scripting, they are.

  4. #4
    Join Date
    Jan 2007
    Location
    Tennessee
    Posts
    642
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    I don't use a version of SCAR that has that feature and i dont have a delphi compiler :/
    So could someone check and tell me?

  5. #5
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    2,984
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    You should really use Scar divi, it's way better...

    procedure OnKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    Administrator's Warning:


  6. #6
    Join Date
    Jan 2007
    Location
    Tennessee
    Posts
    642
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    I use divi but not the current one.
    I have the first one that came out and i can't dl the new one right now.
    But thanks.

  7. #7
    Join Date
    Jan 2007
    Location
    BC, Canada
    Posts
    66
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Exclamation OnKeyPress i need some help

    Im trying to use OnKeyPress to send the text from an edit box into a memo box when i hit the enter key.
    It runs but any key i press in the edit box just plays a ding sound and wont input and keystrokes.
    how do i make this work?

    i can post the rest of the code if you need it.

    Code:
    procedure AddText(Sender: TObject; var Key: Char);
    begin
      Key:= Chr(13); 
      LogBox.Lines.Add(Msg);
      Msg:= InputBox.Text;
      InputBox.Text := '';
    end;
    
    
    
    InputBox.OnKeyPress:= @AddText;

  8. #8
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

    shouldnt it be something like:
    SCAR Code:
    procedure AddText(Sender: TObject; var Key: Char);
    begin
      if key = chr(13) then
      begin
        LogBox.Lines.add(InputBox.Text);
        InputBox.Text := '';
      end;
    end;

  9. #9
    Join Date
    Jan 2007
    Location
    BC, Canada
    Posts
    66
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    yes that works thank you very much. It still dings though when i hit enter. that gets kind of annoying.

  10. #10
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

    Quote Originally Posted by fORCE_wORKS View Post
    yes that works thank you very much. It still dings though when i hit enter. that gets kind of annoying.
    yeah edit field enter = ***ding*** .

    Maybe try adding this to your onkeypress procedure.
    SCAR Code:
    procedure AddText(Sender: TObject; var Key: Char);
    begin
      if key = chr(13) then
      begin
        LogBox.Lines.add(InputBox.Text);
        InputBox.Text := '';
      end;
      if key=chr(13) then
      key:=chr(0);
    end;

  11. #11
    Join Date
    Jan 2007
    Location
    BC, Canada
    Posts
    66
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    oh ya that worked great.
    Even shorted up my code a little by puting the inputbox.text right in there. good call.
    I love it when i can shorten my code up even if its only a couple lines. thx.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •