diff dwt/events/KeyEvent.d @ 34:5123b17c98ef

Ported dwt.events.*, dwt.graphics.GC, Region, dwt.internal.image.*
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Sun, 14 Sep 2008 01:45:57 +0200
parents 1a8b3cb347e0
children 43be986a1372
line wrap: on
line diff
--- a/dwt/events/KeyEvent.d	Fri Sep 12 13:53:21 2008 +0200
+++ b/dwt/events/KeyEvent.d	Sun Sep 14 01:45:57 2008 +0200
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -7,6 +7,8 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
 module dwt.events.KeyEvent;
 
@@ -14,6 +16,9 @@
 
 
 import dwt.widgets.Event;
+import dwt.events.TypedEvent;
+
+import tango.text.convert.Format;
 
 /**
  * Instances of this class are sent as a result of
@@ -30,22 +35,24 @@
  * not necessary to add traversal listeners for these controls,
  * unless you want to override the default traversal.
  * </p>
+ *
  * @see KeyListener
  * @see TraverseListener
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
  */
 
 public class KeyEvent : TypedEvent {
-    
+
     /**
-     * the character represented by the key that was typed.  
+     * the character represented by the key that was typed.
      * This is the final character that results after all modifiers have been
      * applied.  For example, when the user types Ctrl+A, the character value
      * is 0x01.  It is important that applications do not attempt to modify the
      * character value based on a stateMask (such as DWT.CTRL) or the resulting
      * character will not be correct.
      */
-    public char character;
-    
+    public wchar character = '\0';
+
     /**
      * the key code of the key that was typed,
      * as defined by the key code constants in class <code>DWT</code>.
@@ -53,20 +60,20 @@
      * contains the unicode value of the original character.  For example,
      * typing Ctrl+M or Return both result in the character '\r' but the
      * keyCode field will also contain '\r' when Return was typed.
-     * 
+     *
      * @see dwt.DWT
      */
     public int keyCode;
-    
+
     /**
      * the state of the keyboard modifier keys at the time
      * the event was generated, as defined by the key code
      * constants in class <code>DWT</code>.
-     * 
+     *
      * @see dwt.DWT
      */
     public int stateMask;
-    
+
     /**
      * A flag indicating whether the operation should be allowed.
      * Setting this field to <code>false</code> will cancel the operation.
@@ -74,7 +81,7 @@
     public bool doit;
 
     static final long serialVersionUID = 3256442491011412789L;
-    
+
 /**
  * Constructs a new instance of this class based on the
  * information in the given untyped event.
@@ -95,13 +102,9 @@
  *
  * @return a string representation of the event
  */
-public String toString() {
-    String string = super.toString ();
-    return string.substring (0, string.length() - 1) // remove trailing '}'
-        + " character='" + ((character is 0) ? "\\0" : "" + character) + "'"
-        + " keyCode=" + keyCode
-        + " stateMask=" + stateMask
-        + " doit=" + doit
-        + "}";
+public override String toString() {
+    return Format( "{} character={} keyCode={} stateMask={} doit={}}",
+        super.toString[ 0 .. $-2 ],
+        character, keyCode, stateMask, doit );
 }
 }