Jump to content



Photo
- - - - -

How Menu Key Can Be Trapped From C?


  • Please log in to reply
2 replies to this topic

#1 neptune45

neptune45

    Casio Fan

  • Members
  • PipPip
  • 44 posts
  • Gender:Male
  • Location:Madrid (Spain)

  • Calculators:
    fx-9860g Slim

Posted 08 December 2008 - 06:41 PM

Hello,

Does anyone know how the menu key can be trapped from C?

It happens using the text editor program that I have created with the SDK that if the user changes to another application while using the editor, he is not warned that he is about to loose all the data because menu key is not trapped by C function GetKey().

Does anyone have an idea how we can overcome this problem?

Thank you,
Diego.

#2 Andreas B

Andreas B

    Casio Freak

  • Members
  • PipPipPipPip
  • 160 posts
  • Gender:Male
  • Location:Norway

  • Calculators:
    fx-9860G SD

Posted 08 December 2008 - 07:19 PM

Hi!

What you should do is install an exit handler. Make a function that asks for user confirmation and lets the user save the file. Register the function with the SetQuitHandler() function. It will be called once the OS has been told to start another program.

edit: Oh, ad by the way - nice program. After a quick look at the source, i think you can save about 10 to 13kB by replacing sprintf() with a custom-made one. You could also replace some sprintf()-calls with strcpy() where you just copy a string, because sprintf() is a slow beast. Thanks for releasing the code.

Edited by Andreas B, 08 December 2008 - 09:37 PM.


#3 neptune45

neptune45

    Casio Fan

  • Members
  • PipPip
  • 44 posts
  • Gender:Male
  • Location:Madrid (Spain)

  • Calculators:
    fx-9860g Slim

Posted 09 December 2008 - 10:49 PM

Hello Andreas,

Thank you for your hint. I implemented an exit handler with the SetQuitHandler() function and it worked fine. I will update soon the text editor in the web with this change. However, it is a pity that this exit handler does not allow to go back to the application, but anyway the user can save the file before loosing it

Thank you also for the remark about sprintf(). I will take this into account.

Diego.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users