×

Discussion Board

Results 1 to 11 of 11

Thread: key events

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    14

    key events

    Okay I managed to get key events from OfferKeyEventL function. There is a lack in it, in that when I press 2 key it gets 2 only not 'a', 'b' or 'c'. How to get that?

    Here's my code for OfferKeyEventL function
    Code:
    TKeyResponse CtestGuiAppView::OfferKeyEventL(const TKeyEvent& aKeyEvent,
    												TEventCode aType)
    	{
    	
    	if (aType != EEventKey)
    		return EKeyWasNotConsumed;
    	
    	if (aKeyEvent.iCode == EKeyEnter)
    		{
    		return EKeyWasConsumed;
    		}
    	else
    		{
    		inputBuf.Append(aKeyEvent.iCode);
    		DrawNow();
    		return EKeyWasConsumed;
    		}
    	}
    The Draw function is implemented as

    Code:
    void CtestGuiAppView::Draw(const TRect& /*aRect*/) const
    	{
    	// Get the standard graphics context
    	CWindowGc& gc = SystemGc();
    
    	// Gets the control's extent
    	TRect drawRect(Rect());
    	
    	// Clears the screen
    	gc.Clear(drawRect);
    	const CFont* font = CEikonEnv::Static()->TitleFont();
    	gc.UseFont(font);
    	gc.SetPenColor(KRgbBlack);
    	TPoint pos(50, 50);
    	gc.DrawText(inputBuf, pos);
    	
    	}
    One thing else I want is that when the end of line is reached (on screen) it starts printing on the next line (on screen) any hints?

    And how does the code draws text next to the previous character. I mean how does it changes it position the pos is at 50,50.
    Last edited by manzoor10; 2009-02-18 at 14:11.

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: key events

    for getting the FEP input without focusing input control, you should use CPTiEngine: http://wiki.forum.nokia.com/index.ph...guage_variants

    And for the line questions, I quess you need to do your own logic for it. For drawing, just add stuff into buffer and drae the buffer, so you don't need to handle separate characters, and for end of space in the screen, you could check CFont fucntions for checking buffer lenght in pixels.

    anyway, would it be easier to use Editors and let them handle all issues.

  3. #3
    Registered User
    Join Date
    Feb 2009
    Posts
    14

    Re: key events

    and what do you mean by editors in symbian? are there such classes? if so which ones? I might research on them

    and what do you mean by without focusing? Isn't there a simpler way?

    like in a console program using Getch we can get the other characters.

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: key events

    Anyting that is derived from CEikEdwin would do file, you could also search Wiki, check examples from the example section, as well as see SDK examples, they all have editor examples available.

    You gotta have a focus on the editor, or it will not get any key input, see any example with more than one components in it for more information.

    In general console applications end up being more difficult than GUIs, so you would be better by starting with GUI applciations.

  5. #5
    Registered User
    Join Date
    Feb 2009
    Posts
    14

    Re: key events

    OK here is my try...

    Code:
    void CtestGuiAppView::ConstructL(const TRect& aRect)
    	{
    	// Create a window for this application view
    	CreateWindowL();
    	
    	// Instantiate the control
    	iInputBox = new (ELeave)CEikEdwin;
    	iInputBox->SetContainerWindowL(*this);
    	
    	// Create a resource reader
    	TResourceReader reader;
    	iCoeEnv->CreateResourceReaderLC(reader, R_INPUTBOX);
    	iInputBox->ConstructFromResourceL(reader);
    	CleanupStack::PopAndDestroy();
    	iInputBox->SetFocus(ETrue);
    
    	// Set the windows size
    	SetRect(aRect);
    
    	// Activate the window, which makes it ready to be drawn
    	ActivateL();
    	}
    where iInputBox is a *CEikEdwin.

    the resource
    Code:
    RESOURCE EDWIN r_inputbox
    	{
    	maxlength = 511;
    	flags = EEikEdwinWidthInPixels;
    	avkon_flags = EAknEditorFlagNoT9;
    	default_case = EAknEditorLowerCase;
    	allowed_case_modes = EAknEditorUpperCase | EAknEditorLowerCase;
    	allowed_input_modes = EAknEditorTextInputMode | EAknEditorNumericInputMode;
    	default_input_mode = EAknEditorTextInputMode;
    	special_character_table = R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG;
    	}
    here's my OfferKeyEventL function
    Code:
    TKeyResponse CtestGuiAppView::OfferKeyEventL(const TKeyEvent& aKeyEvent,
    												TEventCode aType)
    	{
    	if (iInputBox)
    		{
    		return iInputBox->OfferKeyEventL(aKeyEvent, aType);
    		}
    	else
    		{
    		return CCoeControl::OfferKeyEventL(aKeyEvent, aType);
    		}
    	}



    It is causing panic EIKON-EDWIN 5

  6. #6
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: key events

    looks rather alike : http://wiki.forum.nokia.com/index.ph...in_Text_Editor, but not actually the same, so maybe you could try copying the wiki example directly, or have a look into bigger example at: http://www.forum.nokia.com/info/sw.n...r_Example.html

  7. #7
    Registered User
    Join Date
    Feb 2009
    Posts
    14

    Re: key events


  8. #8
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: key events

    Actually it is not the same, the link I gave has slightly different implementation..

  9. #9
    Registered User
    Join Date
    Feb 2009
    Posts
    14

    Re: key events

    Lol it is just a one line of code... alright

    here is it
    Code:
    	// Instantiate the control
    	iInputBox = new (ELeave)CEikEdwin;
    	iInputBox->SetContainerWindowL(*this);
    	
    	// Create a resource reader
    	TResourceReader reader;
    	iCoeEnv->CreateResourceReaderLC(reader, R_INPUTBOX);
    	iInputBox->ConstructFromResourceL(reader);
    	CleanupStack::PopAndDestroy();
    it is in the ConstructL of View class

    Code:
    RESOURCE EDWIN r_inputbox
    {
    	maxlength = 511;
    	default_case = EAknEditorTextCase;
    	allowed_case_modes = EAknEditorAllCaseModes;
    	numeric_keymap = EAknEditorStandardNumberModeKeymap;
    	default_input_mode = EAknEditorTextInputMode;
    	allowed_input_modes = EAknEditorAllInputModes;
    	special_character_table = R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG;
    }
    the resource file..

  10. #10
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: key events

    Anyway, if it is still not working, you could try one without resource definitions: http://wiki.forum.nokia.com/index.php/Editor_example

  11. #11
    Registered User
    Join Date
    Feb 2009
    Posts
    14

    Re: key events

    I want to know why that code is not working and the features in that class are excessive for requirement.

Similar Threads

  1. Custom Softkeys commands and key events
    By hclemson in forum Symbian User Interface
    Replies: 2
    Last Post: 2008-11-21, 16:37
  2. Key UP and Down events not receving
    By symsta in forum Symbian
    Replies: 5
    Last Post: 2008-09-21, 11:28
  3. Replies: 0
    Last Post: 2007-04-03, 17:22
  4. Opening application and handling key events
    By kawaiimomo in forum Symbian
    Replies: 3
    Last Post: 2005-11-11, 05:11
  5. 3410 losing key events
    By marcpalmer in forum Mobile Java General
    Replies: 4
    Last Post: 2003-09-30, 22:50

Posting Permissions

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