FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

KeyListener

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.     Forum Index -> DWT
View previous topic :: View next topic  
Author Message
ebo



Joined: 19 Dec 2005
Posts: 1

PostPosted: Mon Dec 19, 2005 10:20 am    Post subject: KeyListener Reply with quote

Code:


shell.handleKeyDown(this, &onShellKeyDownEvent);


private void onShellKeyDownEvent(KeyEvent e)
{
   if(isShellClickDisable)
      return;
   else
   {
      MessageBox.showMsg("!!");
      enableAllWidget(true);
   }
}



this is some part of my code

I try grep keyEvent on Shell but I can't grep that.

why I can't?

I use addKeyListener and KeyListener but they don't work too...
[/code]
Back to top
View user's profile Send private message
Shawn Liu



Joined: 09 Mar 2005
Posts: 104
Location: Shanghai, China

PostPosted: Sat Dec 24, 2005 1:11 am    Post subject: Reply with quote

try the following code, use listener, delegate or both.

Code:
private import dwt.all;

class Test{
   private static Shell shell;
   this(Display display){
      this.shell = new Shell(display);
      // method (1)
      {
      shell.addKeyListener(new class KeyListener{
   
         public void keyPressed(KeyEvent e) {
//            shell.setText("keyPressed by listener "  ~ e.toString());
         }
   
         public void keyReleased(KeyEvent e) {
//            shell.setText("key Released by listener "  ~ e.toString());
         }
         
      });
      } // end of method (1)
      // method (2)
      {
      shell.handleKeyDown(null, &onShellKeyDownEvent);
      shell.handleKeyUp(null, &onShellKeyUpEvent);
      } // end of method
   }
   Shell open(){
      shell.open();
      return shell;
   }
   void onShellKeyDownEvent(KeyEvent e){
      shell.setText("keyPressed by delegate " ~ cast(char)e.character);
   }
   void onShellKeyUpEvent(KeyEvent e){
      shell.setText("keyReleased by delegate " ~ cast(char)e.character);
   }
   static void main(char[][] args) {
      Display display = new Display();
      Shell shell = (new Test(display)).open();
      
      shell.open();
      while (!shell.isDisposed()) {
         if (!display.readAndDispatch())
            display.sleep();
      }
      display.dispose();
   }
}

void main(char[][] args){
   Test.main(args);
}
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.     Forum Index -> DWT All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group