×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Mar 2010
    Location
    Austria
    Posts
    9

    Question How to catch caret-Key

    Hi there,

    i want to listen to the "caret-key" (^) on the keyboard.
    in QWidget::keyPressEvent()

    1) is this possible in general?
    because on my system i have to press it twice so see it in an editor (like here in this forum), and then i get 2 of them.

    2) what is the Qt::Key_xxxx enumerator for it?

    I need it for a GUI calculator-application.

    kind regards, Karl

  2. #2
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

  3. #3
    Registered User
    Join Date
    Mar 2010
    Location
    Austria
    Posts
    9

    Re: How to catch caret-Key

    Sorry Daniil for my unprecise manner of expression.

    I ment, its no problem to listen for any key of the keyboard e.g. Digits, Return, Enter, ....
    But what makes my problem is the caret-key. Is there any possible way to get knowing of if it is pressed or not?

    kind regards, Karl

    EDIT: it is the Qt::Key_AsciiCircum (0x5e)
    But still having the problem getting this event only, when i press the key twice...
    Last edited by griffin27; 2010-03-22 at 21:13. Reason: got the name of the key

  4. #4
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: How to catch caret-Key

    On my keyboard it's Qt::Key_Dead_Circumflex.

  5. #5
    Nokia Developer Champion
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: How to catch caret-Key

    Note that on some national language keybaords certain keys may be "mangled" in the keyboard handler. Eg, "^" may be "queued" until the next key is pressed, to see if the next key is a "o", and then, if so, the decimal 147 character will be emitted.

  6. #6
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Re: How to catch caret-Key

    Hi,
    I am currently developing a keyboard based game - and have found out that the best way is an offscreen text field. I have a PlainTextEdit on the form - the rest is in the code below:
    Code:
    #include "QtGameForm.h"
    #include <QKeyEvent>
    #include <QMessageBox>
    #include <aknviewappui.h>
    
    
    QtGameForm::QtGameForm(QWidget *parent)
        : QMainWindow(parent)
    {
    	ui.setupUi(this);
    
    	
    	//arm the decoy field (like on the palm)
    	ui.dummyEdit->grabKeyboard();
    	//ui.dummyEdit->setVisible(false); MUST BE VISIBLE!!!
    	connect(ui.dummyEdit,SIGNAL(textChanged()),this,SLOT(textChanged()));
    	ui.dummyEdit->setGeometry(700,700,2,2); //MOVE OFFSCREEN
    }
    
    QtGameForm::~QtGameForm()
    {
    }
    
    void QtGameForm::textChanged()
    {
    	QString s=ui.dummyEdit->toPlainText();
    	if(s==NULL)return;
    		for(int oi=0;oi<s.length();oi++)
    		{
    			QChar suppliedChar=s[oi];
    			qint32 i;
    			qint32 best_elem=162;
    			qint16 maxdepth=-1;
    			//TOUCHEvtResetAutoOffTimer();
    			for(i=0;i<100;i++)
    				{
    					if(prefs.vars->sign[i]==suppliedChar && prefs.vars->paused==false)
    					{
    						if(maxdepth<prefs.vars->ypos[i])
    						{
    							best_elem=i;
    							maxdepth=prefs.vars->ypos[i];
    						}
    					}
    				}
    
    				if(best_elem<162) //it is set to 162 by default, if nothing is found
    				{
    					if(prefs.consts->players==1)
    					{
    						prefs.chars_hit[prefs.vars->sign[best_elem]]++;
    					}
    					prefs.vars->sign[best_elem]=NULL;
    					prefs.vars->xpos[best_elem]=NULL;
    					prefs.vars->ypos[best_elem]=NULL;
    					prefs.consts->hitChars++;
    					prefs.consts->hitstroke++;
    					prefs.consts->charsonscreen--;
    					if(prefs.consts->lifeleft<158)
    					{
    						prefs.consts->lifeleft++;
    					}
    				}
    		
    		
    		}
    		ui.dummyEdit->setPlainText(QString(""));
    }
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

Similar Threads

  1. Yucca please help: Long key press - iRepeats is never 1
    By Tasneem Rangwala in forum Symbian
    Replies: 1
    Last Post: 2009-10-28, 03:32
  2. not getting send (call or green) key event
    By vasant21 in forum Symbian
    Replies: 2
    Last Post: 2007-01-09, 17:31
  3. GameCanvas Middle Soft Key Problem
    By nnigel in forum Mobile Java General
    Replies: 5
    Last Post: 2006-06-27, 11:14
  4. Handling simultaneous key presses in game
    By e_morko in forum Symbian
    Replies: 2
    Last Post: 2005-01-20, 15:03
  5. How to get the value of key event in nokia 7650
    By zy_fly in forum Symbian User Interface
    Replies: 2
    Last Post: 2003-12-02, 22:46

Posting Permissions

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