Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Adding *, +, -, and ^ as a ShortCut to a TMenuItem

iDaZeiDaZe Member Posts: 464
Like the subject says ...

I have a PopupMenu on my form and I need to have +, -, * and ^ as the ShortCut properties, but Delphi won't allow it. I tried adding it at runtime using the ShortCut() and TextToShortCut() functions, but that doesn't work either.
And I know there has to be some way because I've seen programs that have those characters as shortcuts.

Thanks

Comments

  • zibadianzibadian Member Posts: 6,349
    : Like the subject says ...
    :
    : I have a PopupMenu on my form and I need to have +, -, * and ^ as the ShortCut properties, but Delphi won't allow it. I tried adding it at runtime using the ShortCut() and TextToShortCut() functions, but that doesn't work either.
    : And I know there has to be some way because I've seen programs that have those characters as shortcuts.
    :
    : Thanks
    :
    It works fine in D5. Just type a & before the shortcut character. I tested it using a TMainMenu with '&-Test' as caption.
  • iDaZeiDaZe Member Posts: 464
    : : Like the subject says ...
    : :
    : : I have a PopupMenu on my form and I need to have +, -, * and ^ as the ShortCut properties, but Delphi won't allow it. I tried adding it at runtime using the ShortCut() and TextToShortCut() functions, but that doesn't work either.
    : : And I know there has to be some way because I've seen programs that have those characters as shortcuts.
    : :
    : : Thanks
    : :
    : It works fine in D5. Just type a & before the shortcut character. I tested it using a TMainMenu with '&-Test' as caption.
    :
    The & shortcut wasn't really what I meant, but I found a way to get it to work. I iterated through all 65526 possible values and used ShortCutToText to see where the * and + where (106 and 107).
    The good news is that they work as shortcuts, the bad news is that it displays "num *" and "num +" instead of just "*" and "+"

    Think I'll need to do some API work to get it the way I want ... if I only knew which api's :-(
  • zibadianzibadian Member Posts: 6,349
    [b][red]This message was edited by zibadian at 2002-10-15 2:21:15[/red][/b][hr]
    [b][red]This message was edited by zibadian at 2002-10-15 2:15:32[/red][/b][hr]
    : : : Like the subject says ...
    : : :
    : : : I have a PopupMenu on my form and I need to have +, -, * and ^ as the ShortCut properties, but Delphi won't allow it. I tried adding it at runtime using the ShortCut() and TextToShortCut() functions, but that doesn't work either.
    : : : And I know there has to be some way because I've seen programs that have those characters as shortcuts.
    : : :
    : : : Thanks
    : : :
    : : It works fine in D5. Just type a & before the shortcut character. I tested it using a TMainMenu with '&-Test' as caption.
    : :
    : The & shortcut wasn't really what I meant, but I found a way to get it to work. I iterated through all 65526 possible values and used ShortCutToText to see where the * and + where (106 and 107).
    : The good news is that they work as shortcuts, the bad news is that it displays "num *" and "num +" instead of just "*" and "+"
    :
    : Think I'll need to do some API work to get it the way I want ... if I only knew which api's :-(
    :
    The & character before another character makes the second character the shortcut. So my example shows '-Test' with the '-' as the shortcut.
    Have you also tried this?
    [code]
    MenuItem.ShortCut := ShortCut(Ord('-'), []);
    [/code]

  • iDaZeiDaZe Member Posts: 464
    : [b][red]This message was edited by zibadian at 2002-10-15 2:21:15[/red][/b][hr]
    : [b][red]This message was edited by zibadian at 2002-10-15 2:15:32[/red][/b][hr]
    : : : : Like the subject says ...
    : : : :
    : : : : I have a PopupMenu on my form and I need to have +, -, * and ^ as the ShortCut properties, but Delphi won't allow it. I tried adding it at runtime using the ShortCut() and TextToShortCut() functions, but that doesn't work either.
    : : : : And I know there has to be some way because I've seen programs that have those characters as shortcuts.
    : : : :
    : : : : Thanks
    : : : :
    : : : It works fine in D5. Just type a & before the shortcut character. I tested it using a TMainMenu with '&-Test' as caption.
    : : :
    : : The & shortcut wasn't really what I meant, but I found a way to get it to work. I iterated through all 65526 possible values and used ShortCutToText to see where the * and + where (106 and 107).
    : : The good news is that they work as shortcuts, the bad news is that it displays "num *" and "num +" instead of just "*" and "+"
    : :
    : : Think I'll need to do some API work to get it the way I want ... if I only knew which api's :-(
    : :
    : The & character before another character makes the second character the shortcut. So my example shows '-Test' with the '-' as the shortcut.
    : Have you also tried this?
    : [code]
    : MenuItem.ShortCut := ShortCut(Ord('-'), []);
    : [/code]
    :
    :

    Yes but that doesn't work like you would expect. There is no connection between the input for ShortCut() and the Ord() value of characters. ShortCut(Ord('-'), []); actually sets "Ins" (Insert-button) as the shortcut and nothing at all for *, + and ^.
    Thanks anyway
  • Shawn CarterShawn Carter Member Posts: 0

    _____ ( http://forcoder.org ) free video tutorials and ebooks about ( Ruby Swift Go PL/SQL Visual Basic .NET Python R C# Objective-C C++ Visual Basic Java Scratch JavaScript C PHP Perl MATLAB Assembly Delphi Erlang Clojure Prolog Julia ABAP Alice Apex Ada VBScript SAS COBOL Crystal Kotlin F# Bash Lisp Hack Awk Transact-SQL ML Rust LabVIEW Logo Fortran Dart Scala Lua Scheme FoxPro D ) _

Sign In or Register to comment.