English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
keyboard mapping with lablgtk2
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-02-15 (20:09)
From: Christian Schlager <Christian.Schlager@t...>
Subject: keyboard mapping with lablgtk2
hi there,

i want to create a special keyboard mode for creating tables in a textview widget with lablgtk2.
To create one row the user should move with ENTER from cell to cell until the end is reached 
and then ENTER to the next row:

this is my callback-function:

let key_pressed (textview:GText.view) (ev:GdkEvent.Key.t) =
  let newch = GdkEvent.Key.string ev in
  let buffer = textview#buffer in
  let iter = buffer#end_iter in
  if (newch = "\n") then
    buffer#insert ~iter "   "
    buffer#insert ~iter newch;

For now it should insert empty spaces when ENTER is hit. Unfortunately it
doesn't work, it just inserts a new line.
Also, the functionality of the keyboard is limited, the backspace key for 
instance doesn't work, but i could work around that thing.
Who can tell me how to correctly test the keys?
A code snippet might be helpful, too.

Thanks for help,