Global on-key

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Toosheds
    Indigo Rose Customer
    • Mar 2004
    • 53

    Global on-key

    Is it possible to make a global version of an on-key action? After making several multiple page presentations, the custopmer wants the escape key to close the application. I dread having to enter this into each page's on_key properties page. Is there an easier way?


    if e_Key == 27 then

    nChoice = Dialog.Message("Confirm", "You sure you wanna close?", MB_YESNO, MB_ICONQUESTION, MB_DEFBUTTON2);
    if nChoice == 6 then
    Application.Exit(0);
    end
    end
  • longedge
    Indigo Rose Customer
    • Aug 2003
    • 2496

    #2
    AFAIK there's no way round the fact that on every page you've got to have something in your 'On Key' event, but it only takes a second to paste a block of text in anyway.

    Comment

    • Adam
      Indigo Rose Staff Member
      • May 2000
      • 2148

      #3
      Or you could create a function in the global functions section such as:
      Code:
      function escaper (e_Keyer)
           if e_Keyer == 27 then
                 nChoice = Dialog.Message("Confirm", "You sure you wanna close?", MB_YESNO, MB_ICONQUESTION, MB_DEFBUTTON2);
                if nChoice == 6 then 
                      Application.Exit(0);
                end
            end
      end
      Then on each page -> Properties -> Actions -> On Key event you could have:

      Code:
      escaper(e_Key);
      This way if you ever want to change this dialog you could do so in one place and have it reflected on every page. This type of situation is just begging for a function

      Adam Kapilik

      Comment

      • Corey
        Indigo Rose Staff Alumni
        • Aug 2002
        • 9741

        #4
        Adam is right. That's the best way to handle this scenario by far.

        Comment

        • longedge
          Indigo Rose Customer
          • Aug 2003
          • 2496

          #5
          ................................................ I was going to comment on the fact that this is a completed project and so a slightly different scenario but on second thoughts it doesn't make a difference really.

          Adams logic is impeccable and cannot be argued with (It's actually what I have done myself in the past )
          Last edited by longedge; 01-14-2005, 12:30 AM. Reason: A change of mind......

          Comment

          • csd214
            Forum Member
            • Oct 2001
            • 939

            #6
            But the page must have the focus?

            All input boxes (for instance) must have something like
            if e_Key == 27 then
            escaper(e_Key);
            end

            Comment

            • longedge
              Indigo Rose Customer
              • Aug 2003
              • 2496

              #7
              Originally posted by csd214
              But the page must have the focus?

              All input boxes (for instance) must have something like
              if e_Key == 27 then
              escaper(e_Key);
              end
              Yes, as I recall, I couldn't get it to work unless I actually tested e_Key in the page 'On Key' event so I ended up doing as you have suggested but just tested for >0. At the time, I had got it to work so I thought no more about it until I saw your post.

              Comment

              • Worm
                Indigo Rose Customer
                • Jul 2002
                • 3967

                #8
                Here's another approach. A global function, and a call in the page timer, no need to worry about On Key events. It also seems to work if you're in a browser object textbox.

                Something different anyway.
                Attached Files
                Last edited by Worm; 01-14-2005, 11:32 AM.

                Comment

                • longedge
                  Indigo Rose Customer
                  • Aug 2003
                  • 2496

                  #9
                  another piece of genius - and an e_Key reference manual to boot :yes

                  Comment

                  • Worm
                    Indigo Rose Customer
                    • Jul 2002
                    • 3967

                    #10
                    IR provided that VirtualKeyCodes table. You can find it in the Gallery\Scriptlets.

                    Comment

                    • Toosheds
                      Indigo Rose Customer
                      • Mar 2004
                      • 53

                      #11
                      Wow

                      Was out of town for a few days .. thanks for the help! Both solutions seem promising. I am hoping Worm's script will work on a page with an ActiveX control or Java applet running in a web object.

                      Comment

                      Working...
                      X