Hi,
I have an extremely simple pys60 script under development. It's about as simple as you make: show a color. Just one color. Full screen.
So far I've rewritten the #%#¤ script 5 times, because keyboard handling is pretty darn hard in pys60.
The first version used a busy loop, which mostly worked, but I just don't like busy loops. The keyboard handling turned into 100 LOC monster, which just got out of control for this kind of app. Too many special cases with different states of script: state machine with as many as 3 states !!!Ok, counting "starting" and "exiting" that's 5 states. Got some crashes, when pressing keys at the wrong time. Crashes are not allowed. Ever. No excuses.
Current version uses binding keypresses to functions, which then are supposed to take care of some things. The problem is that I get 3 events per one physical finger press... I can feel special cases creeping in again, this time into about 15 different places.
Latest plan number 6 is to combine both key event binding AND one central messy key handling function - but I'm getting tired of having such basic problems for such basic app. I mean, I just want to show one color
Question:
Any recommendations about a reusable, reliable and simple way to handle key events? Wiki has one code sample, which has got one review: one point out of five. That's not a good recommendation for a sample, at least not to me. Also I tried that once already.
Yep, I got the "mobile Python" book and I tried their code in version 3, I guess. Not much improvement over default Nokia sample. Messy.
Cheers,
--jouni who wants one event for one key press UNLESS he especially requests to get more events

Ok, counting "starting" and "exiting" that's 5 states. Got some crashes, when pressing keys at the wrong time. Crashes are not allowed. Ever. No excuses.
Reply With Quote


