PHP-GTK2 Cookbook Forum
Welcome, Guest
Please Login or Register.    Lost Password?
keypress event problem (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: keypress event problem


#799
edryan (User)
Junior Boarder
Posts: 21
graphgraph
User Offline Click here to see the profile of this user
keypress event problem 3 Years, 8 Months ago Karma: 0  
hi guyz,

i got this working properly but i got problem on the key press entry because IT RECOGNIZES ONLY THE SECOND INPUT FROM THE KEYBOARD..
here's the codes..

$entry = new GtkEntry();
$entry->connect_simple('key-press-event',array($this,'onkeypress'));
$entry2= new GtkEntry();

function onkeypress(){
$entry->add_events(Gdk::KEY_PRESS_MASK);
$data = $entry->get_text();

//make some calculations
$data = $data * 2;

//distribute the calculated data
$entry2->set_text($data);
}
 
  The administrator has disabled public write access.

#806
XeKtRuM (User)
Fresh Boarder
Posts: 15
graphgraph
User Offline Click here to see the profile of this user
Re:keypress event problem 3 Years, 8 Months ago Karma: 0  
Hi there, the code you paste here has a lots of bugs, ie:

Why are you using "array($this,..." if you are not in Object Oriented context?
$entry and $entry2 are in both cases local variables and they are out of scope. You need to pass this variables to the onkeypress function.

So, if you could paste the whole code here or paste it on http://pastebin.com, so we could see the whole deal and help you out.
 
  The administrator has disabled public write access.

#808
edryan (User)
Junior Boarder
Posts: 21
graphgraph
User Offline Click here to see the profile of this user
Re:keypress event problem 3 Years, 8 Months ago Karma: 0  
ok...im sori, i haven't told in my post..its a class that extends GtkWindow so that's why i used '$this' in the array...

but the whole concept of the key press problem is in that part..it doesn't need the whole codes.

here's the code modification..
Code:
$entry = new GtkEntry();
$entry->connect_simple('key-press-event','onkeypress'));
$entry2= new GtkEntry();

function onkeypress(){
   
    $entry->add_events(Gdk::KEY_PRESS_MASK);
    $data = $entry->get_text();

    //make some calculations
    $data = $data * 2;

    //distribute the calculated data
    $entry2->set_text($data);
} 
is "Gdk::KEY_PRESS_MASK" really necessary??how does it work??
 
  The administrator has disabled public write access.



Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Blog - Forum - Privacy Policy - Contact Us
Copyright © 2006-2012. kksou.com. All Rights Reserved