Pop-up Keyboard - Need some input

Hi All,

I am trying to add a pop-up keyboard into my application. This is mainly to be used with a touch screen interface.

I've got the keyboard created and am able to input data into my forms.

I'd like suggestions on the best way to implement loading the keyboard. The application can be used with a touchscreen or an actual keyboard. 

I have tested some code to put an icon in the title bar which would show the pop-up keyboard, but I have some dialogs, showmodal windows, etc. that have no title bar and I'm not sure if I want to change them all. If this were the case and I added a title bar, would there be a way to have one procedure draw the icon on any form with a title bar without having to call the procedure from every form?

I have also considered setting an option in my configuration which would allow the user to specify whether or not they are using a touchscreen. I guess I could then pop up the keyboard when they enter an editable field. Is there a global hook I could use in my application to catch when a user enters and editable field using RTTI or something like that?

Also, thought I'd mention that my application does not use a main menu, so putting it there would do no good for me.

Any comments, suggestions and other options would be greatly appreciated!

Thanks,
Stacey

Edited by: Stacey Brodsky on Aug 13, 2008 8:40 AM
0
Stacey
8/13/2008 3:42:26 PM
embarcadero.delphi.general 4258 articles. 0 followers. Follow

5 Replies
1249 Views

Similar Articles

[PageSpeed] 6
Get it on Google Play
Get it on Apple App Store

Stacey Brodsky wrote:

> Hi All,
> 
> I am trying to add a pop-up keyboard into my application. This is
> mainly to be used with a touch screen interface.
> 
> I've got the keyboard created and am able to input data into my forms.
> 
> I'd like suggestions on the best way to implement loading the
> keyboard. The application can be used with a touchscreen or an actual
> keyboard.
> 
> I have tested some code to put an icon in the title bar which would
> show the pop-up keyboard, but I have some dialogs, showmodal windows,
> etc. that have no title bar and I'm not sure if I want to change them
> all. If this were the case and I added a title bar, would there be a
> way to have one procedure draw the icon on any form with a title bar
> without having to call the procedure from every form?
> 
> I have also considered setting an option in my configuration which
> would allow the user to specify whether or not they are using a
> touchscreen. I guess I could then pop up the keyboard when they enter
> an editable field. Is there a global hook I could use in my
> application to catch when a user enters and editable field using RTTI
> or something like that?
> 
> Also, thought I'd mention that my application does not use a main
> menu, so putting it there would do no good for me.
> 
> Any comments, suggestions and other options would be greatly
> appreciated!
> 
> Thanks,
> Stacey
> 
> Edited by: Stacey Brodsky on Aug 13, 2008 8:40 AM


Check out Peter Bellow's outstanding CodeCentral entry:
http://cc.codegear.com/Item/25888

It's everything you ever want to know how to do with the keyboard in
win32.
0
Joe
8/13/2008 4:46:59 PM
Stacey Brodsky wrote:
> Hi All,
> 
> I am trying to add a pop-up keyboard into my application. This is mainly to be used with a touch screen interface.
> 
> I've got the keyboard created and am able to input data into my forms.
> 
> I'd like suggestions on the best way to implement loading the keyboard. The application can be used with a touchscreen or an actual keyboard. 
> 
> I have tested some code to put an icon in the title bar which would show the pop-up keyboard, but I have some dialogs, showmodal windows, etc. that have no title bar and I'm not sure if I want to change them all. If this were the case and I added a title bar, would there be a way to have one procedure draw the icon on any form with a title bar without having to call the procedure from every form?
> 
> I have also considered setting an option in my configuration which would allow the user to specify whether or not they are using a touchscreen. I guess I could then pop up the keyboard when they enter an editable field. Is there a global hook I could use in my application to catch when a user enters and editable field using RTTI or something like that?
> 
> Also, thought I'd mention that my application does not use a main menu, so putting it there would do no good for me.
> 
> Any comments, suggestions and other options would be greatly appreciated!
> 
> Thanks,
> Stacey
> 

Stacey,

If you need a full blown keyboard with all the goodies, I'd suggest taking a 
look at TMS Software:
http://www.tmssoftware.com/site/atkbd.asp

If you just want a simple one that does ascii chars, etc, I have attached a unit 
that give you an idea or two.

--
Warm Regards,



unit dlg_keyboard;

interface

uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
   Dialogs, StdCtrls, ExtCtrls

   ,keyboard_observer,base_pos_screen, pos_button
   ;

type
   TDlgKeyboard = class(TBasePOSScreen)
     btnQ: TPOSButton;
     btnW: TPOSButton;
     btnE: TPOSButton;
     btnR: TPOSButton;
     btnT: TPOSButton;
     btnY: TPOSButton;
     btnU: TPOSButton;
     btnI: TPOSButton;
     btnO: TPOSButton;
     btnP: TPOSButton;
     btnA: TPOSButton;
     btnS: TPOSButton;
     btnD: TPOSButton;
     btnF: TPOSButton;
     btnG: TPOSButton;
     btnH: TPOSButton;
     btnJ: TPOSButton;
     btnK: TPOSButton;
     btnL: TPOSButton;
     btnZ: TPOSButton;
     btnX: TPOSButton;
     btnC: TPOSButton;
     btnV: TPOSButton;
     btnB: TPOSButton;
     btnN: TPOSButton;
     btnM: TPOSButton;
     btnSpace: TPOSButton;
     btn3: TPOSButton;
     btn2: TPOSButton;
     btn1: TPOSButton;
     btn6: TPOSButton;
     btn5: TPOSButton;
     btn4: TPOSButton;
     btn9: TPOSButton;
     btn8: TPOSButton;
     btn7: TPOSButton;
     btnDot: TPOSButton;
     btn0: TPOSButton;
     btnMinus: TPOSButton;
     btnPlus: TPOSButton;
     btnBackSpace: TPOSButton;
     btnClear: TPOSButton;
     btnShift1: TPOSButton;
     btnShift2: TPOSButton;
     eText: TEdit;
     shpBorderShape: TShape;
     Procedure btnShift1ButtonClick( Sender: TObject) ;
     Procedure FormCreate( Sender: TObject) ;
     Procedure FormDestroy( Sender: TObject) ;
   Private
     FKeyboardObvserver: TKeyboardObserver;
     FIsUpper: boolean;
     procedure   RegisterButtons;
     procedure   ChangeKeyCase(ToUpper: boolean);
     procedure   HandleEnterKey(Sender: TObject);
     procedure   HandleCancelKey(Sender: TObject);
   Public
     // ---> Methods
    class function GetKeyboardText(var AString: string): boolean;
   end;

var
   DlgKeyboard: TDlgKeyboard;

implementation

{$R *.dfm}

uses
   pos_application
   ;

{ TBasePOSScreen3 }

procedure TDlgKeyboard.btnShift1ButtonClick(Sender: TObject);
begin
   FIsUpper := not FIsUpper;
   ChangeKeyCase(FIsUpper);
end;


procedure TDlgKeyboard.ChangeKeyCase(ToUpper: boolean);
var
   i: integer;
   lButton: TPOSButton;
Begin
   for i :=0 to ComponentCount -1 do
     begin
       if (Components[i] is TPOSButton) and (Components[i].Tag = 1) then
         begin
           lButton := TPOSButton(Components[i]);
           if ToUpper then
             lButton.Caption := UpperCase(lButton.Caption)
           else
             lButton.Caption := LowerCase(lButton.Caption);
         end;
     end;

end;

procedure TDlgKeyboard.FormCreate(Sender: TObject);
begin
   inherited FormCreate(Sender);
   FKeyboardObvserver := TKeyboardObserver.Create(eText);
   FKeyboardObvserver.OnEnterKey := HandleEnterKey;
   FKeyboardObvserver.OnCancelKey := HandleCancelKey;
   RegisterButtons;
end;

procedure TDlgKeyboard.FormDestroy(Sender: TObject);
begin
   FKeyboardObvserver.Free;
end;

class function TDlgKeyboard.GetKeyboardText(var AString: string): boolean;
var
   lForm: TDlgKeyboard;
Begin
   lForm := TDlgKeyboard.Create(nil);
   try
     result := lForm.ShowModal = mrOK;
     if result then
       AString := lForm.eText.Text;
   finally;
     lForm.free;
     end;

end;

procedure TDlgKeyboard.HandleCancelKey(Sender: TObject);
begin
   ModalResult := mrCancel;
end;

procedure TDlgKeyboard.HandleEnterKey(Sender: TObject);
begin
   if eText.Text = '' then
     exit; //==>
   ModalResult := mrOK;
end;

procedure TDlgKeyboard.RegisterButtons;
var
   i: integer;
Begin
   for i :=0 to ComponentCount -1 do
     begin
       if (Components[i] is TPOSButton) and (Components[i].Tag <> 2) then
         begin
           FKeyboardObvserver.RegisterButton(TPOSButton(Components[i]));
         end;
     end;

end;

end.
0
Lee
8/13/2008 5:04:53 PM
Stacey Brodsky wrote:

> I am trying to add a pop-up keyboard into my application. This is
> mainly to be used with a touch screen interface.
> 
> I've got the keyboard created and am able to input data into my forms.
> 
> I'd like suggestions on the best way to implement loading the
> keyboard. The application can be used with a touchscreen or an actual
> keyboard.

> I have tested some code to put an icon in the title bar which would
> show the pop-up keyboard, but I have some dialogs, showmodal windows,
> etc. that have no title bar and I'm not sure if I want to change them
> all. If this were the case and I added a title bar, would there be a
> way to have one procedure draw the icon on any form with a title bar
> without having to call the procedure from every form?

Would be difficult but not impossible. You would need to use a
thread-specific WH_CALLWNDPROC hook to catch the relevant non-client
area messages to paint a fake button on the caption and to react to
clicks on it.

A touch-screen app is often used as the only app running (or at least
as a full screen app). How about placing floating button (basically a
topmost borderless form drawn like a button that refuses to get
disabled, so it will stay clickable even if a modal dialog is up) in
one corner of the screen to activate the keypad? Handle
WM_MOUSEACTIVATE on the form to detect clicks on it and to prevent it
from being activated. Handle WM_ENABLE to make the form immune from
disabling:

 Procedure WMEnable( Var msg: TWMEnable ); message WM_ENABLE;
 
and implement it as 

Procedure TMySpecialForm.WMEnable( Var msg: TWMEnable ); 
Begin
  inherited;
  If not msg.enabled Then
    EnableWindow( handle, true );
End;    

> I have also considered setting an option in my configuration which
> would allow the user to specify whether or not they are using a
> touchscreen. I guess I could then pop up the keyboard when they enter
> an editable field.

That would be a good option, IMO. 

> Is there a global hook I could use in my
> application to catch when a user enters and editable field using RTTI
> or something like that?

There is the Screen.OnActiveControlChange event. It may serve your
purpose. Inside the event Screen.Activecontrol gives you the focused
control, you can check if it's one of those editable via the keyboard.
If not, hide the keyboard if it is showing, if yes, show the keyboard.


-- 
Peter Below (TeamB)  
Don't be a vampire (http://slash7.com/pages/vampires), 
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
0
Peter
8/13/2008 6:01:14 PM
Thanks to all who replied! Great ideas and suggestions have led me to a pretty good implementation of the keyboard =)

I ended up going with a configuration option. If the option is set to TouchScreen, I then use the Screen.ActiveControlChange and  RTTI to determine whether to pop the keyboard up or not.

Thanks again.
0
Stacey
8/13/2008 9:05:55 PM
<Stacey Brodsky> wrote in message news:2137@forums.codegear.com...

> I am trying to add a pop-up keyboard into my application. This is
> mainly to be used with a touch screen interface.

What about using the on-screen keyboard that is built into Windows itself? 
Have a look at osk.exe

> I have also considered setting an option in my configuration which would
> allow the user to specify whether or not they are using a touchscreen. I 
> guess
> I could then pop up the keyboard when they enter an editable field. Is 
> there
> a global hook I could use in my application to catch when a user enters 
> and
> editable field using RTTI or something like that?

No.  You would have to use the OnEnter event for each component.


Gambit
0
Remy
8/13/2008 10:27:50 PM
Reply:

Similar Artilces:

keyboard input
dear all; i don't know how to find out which keyboard a keystroke came from on systems with more than one keyboard attached. please help. tia Boba wrote: > i don't know how to find out which keyboard a keystroke came > from on systems with more than one keyboard attached. Normal keyboard input does not differentiate between multiple keyboards (same with multiple mice). The only way to differentiate is to use the Raw Input API that was introduced in XP to receive input events from specific hardware devices: http://msdn.microsoft.com/en-us/library/windows/d...

delphi.general
Sorry if this is "out of topic"! but since some days ago I can't read the group *embarcadero.public.delphi.language.delphi.general* Does anybody know if there's something wrong with it? Or maybe is my reader? (Thunderbird) I get this messagge when I try to read the latest messages: Error! newsgroup server responded:no such article found Perhaps the article has expired <692702@forums.embarcadero.com> (33145) Click here to remove all expired articles sergio wrote: > Sorry if this is "out of topic"! but since some days ago I can'...

What generals generally do
Reading a McChrystal thread elsewhere, I came across someone quoting a US general http://en.wikipedia.org/wiki/Smedley_Butler > I spent 33 years and four months in active military service and > during that period I spent most of my time as a high class thug for > Big Business, for Wall Street and the bankers. In short, I was a > racketeer, a gangster for capitalism. I helped make Mexico and > especially Tampico safe for American oil interests in 1914. I helped > make Haiti and Cuba a decent place for the National City Bank boys to > collect revenues in. I ...

input from keyboard
Hi, I'm wanted to test a program on my linux OS with perl, i want to create a program that knows what key your are pressing, off course you say, <enter a word> a < the word was> a but i mean while you type the perl program can memorize what you type, is there any module out there?? thanx On Mon, 5 May 2003, anthony wrote: > Hi, > > I'm wanted to test a program on my linux OS with perl, i want to create a > program that knows what key your are pressing, off course you say, > <enter a word> > a > < the word was> a &...

Keyboard input
Does anybody know how to send key strokes to the keyboard input buffer? From my PB app, I need to be able to send keystrokes to any application I choose, as if the user had keyed them. I tried messing around with the PostMessage API function and was able to send the ENTER key to the receiving window - refer code below - but I was not able to send alphanumeric characters to fields. Windows seems to just ignore them... Example of sending keystrokes using PostMessage, this example attempts to send keystrokes to the Compose New Fax window from Windows'95 Messaging:- // defin...

Perl Newbie question: How would you take keyboard input and run a shell scrip with that input?
For example: I would like for the user to enter the name of a software package to use and then call a shell script to use that package name to upgrade software. Thanks ===== Jeffrey T. Collins jtbaca@yahoo.com __________________________________ Do you Yahoo!? Find out what made the Top Yahoo! Searches of 2003 http://search.yahoo.com/top2003 I don't think you could be vaguer :) Very basic #!/usr/bin/perl # update.pl multiple options command line my @packages = @ARGV foreach (@packages){ system(packageexecutableforupdate); #with output captured My $output ...

Keyboard behavior change for <input type="number"> and <input x-inputmode="numeric">
Greetings everyone, Starting with bug 1024298 (which has landed), for <input type="number"> [1] and <input type="text" x-inputmode="numeric"> input fields, we bring up the full keyboard, instead of the old four-by-three digit-only numpad. The full keyboard brought up is defaulted to display the number panel first. [1] This excludes <input type="number" x-inputmode="digit">, for which the numpad panel would display. As this change is system-wide, I'd like to invite you to kindly check that it has not br...

Flash Keyboard Input
Name: Jordan Email: jordanreuteratgmaildotcom Product: Firefox Summary: Flash Keyboard Input Comments: I don't know why, but whenever I run a flash file that requires the input of any keys, Firefox doesn't respond correctly. Keyboard input functions normally under Firefox 2 (thankfully), but it just sort of freezes up in 3rc1. Browser Details: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9) Gecko/2008051202 Firefox/3.0 From URL: ...

keyboard input stops
Name: Paul Oratofsky Email: oratofskyatyahoodotcom Product: Firefox Summary: keyboard input stops Comments: Occasionally, when I change from one tabbed window to another and return to the first, all keyboard input is cut off and the only way I've found to restore it is to relaunch Firefox. Browser Details: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14 From URL: http://hendrix.mozilla.org/ ...

Keyboard pop up event?
I'm running 9.0.2.3302 on Windows Mobile 5 Pocket PC. This is more of a Pocket PC question, but I don't know where else to look. Does anyone know how to detect the presense of the soft key board on devices without a physical keyboard? Some apps will resize the UI so that the keyboard does not cover up the app when the keyboard is up. We want to do something like that in our app. I haven't been able to find this event (if it is an event). Thanks! See sybase.public.pocketpowerbuilder On 20 Jul 2006 08:54:14 -0700, Madhu Siddalingaiah <msiddalingaiah@bcbsal...

Keyboard input does not work
hi, i'm trying to play with the win32_test source code using vs2008. compilation and running the exe work without any glitch. (thanks for the very organized source code and documentation!). i've noticed that keyboard handling does not work. i'm displaying google's top page, but can't type anything into search box. i tried to use visual studio's spy to check if any window messages are sent, but apparently no keyboard messages are sent/handled. on the other hand, mouse handling works, though. any help would be appreciated. cheers, andy ...

not responding to keyboard input
Name: David Josselyn Email: dmjossel_at_synfibers.com Product: Firefox 2 Beta 2 Summary: not responding to keyboard input Comments: My only persistent issue so far is that the app sometimes fails to respond to keyboard input. Clicking to take the focus away from the Firefox window and then back usually fixes this. It affects not just typing in the URL bar, but also keyboard shortcuts. Browser Details: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1b2) Gecko/20060821 Firefox/2.0b2 ...

keyboard input language
Name: Black Wind Product: Firefox Summary: keyboard input language Comments: hi mozillas, i am a dedicate user of firefox, thers a feedback, more like a request its about the input language it wud be great if u make firefox remembers the input keyboard language 4 each tab and thaks a lot for firefox keep it up sorry 4 my bad english Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.2) Gecko/20100115 Firefox/3.6 From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this feedback but if you wish to provide o...

No keyboard-input on X
I have 2 servers connected to 1 monitor and 1 keyboard. Both servers where running on openSUSE 11.3. Everything worked fine until i upgraded 1 server to openSUSE 11.4. Now my keyboard doesn't work anymore. When I boot-up I can hit enter to boot into desktop but after SUSE begins to load, the keyboard doesn't work anymore. A usb-keyboard works fine and the hardware list shows the keyboard. What have caused this problem ? anybody experienced the same problem ? /etc/X11/xorg.conf.d/90-keytable.conf > > Section "InputClass" > Identifier "Local...

Input data and keyboards
I'm working on a website to collect information from all over the world to be published in English. The information will be keyed by the user into an English language form.    While the final publication can cope with accents, umlauts and the like, Russian, Greek and Asian languages are not going to work.   So how can I make sure that the input uses Western European characters only?...