Virtual Keyboard

Virtual Keyboard

Postby Euclides » Fri Dec 05, 2008 12:05 pm

Hi to all.
I am implementing a Virtual Keyboard in a routine using:
oGet:SetFocus(), oGet:KeyChar(nKey)
Character fields works well, even together with the regular keyboard.
With numeric field with a PICTURE, it only keeps the last number entered.
TIA for any sugestions.
Regards, Euclides
User avatar
Euclides
 
Posts: 156
Joined: Wed Mar 28, 2007 1:19 pm

Postby James Bott » Fri Dec 05, 2008 3:56 pm

Euclides,

I'm not sure exactly what you are doing, but nKey is the last key entered.

Are you using oGet:varGet() to get the contents of the field?

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Euclides » Fri Dec 05, 2008 4:50 pm

Hi James,
Mainly i am doing the following:

cNr=space(10); nNr=0
REDEFINE GET oGet[1] VAR cNr ID 102 OF oDlg1
oGet[1]:bGotFocus:={|| nX:=1 }
REDEFINE GET oGet[2] VAR nNr ID 101 OF oDlg1 PICTURE "@E 999.99"
oGet[2]:bGotFocus:={|| nX:=2 }
REDEFINE BUTTON ID 10 OF oDlg1 ACTION ( oGet[nX]:SetFocus(), oGet[nX]:KeyChar(asc("0")))
REDEFINE BUTTON ID 11 OF oDlg1 ACTION ( oGet[nX]:SetFocus(), oGet[nX]:KeyChar(asc("1")))

The character field fills OK but the numeric field overwrites the whole field with the number typed
I planned to use the TGET class methods to build the numbers.
Thanks for jumping in, regards.
Euclides
User avatar
Euclides
 
Posts: 156
Joined: Wed Mar 28, 2007 1:19 pm

Postby James Bott » Fri Dec 05, 2008 5:21 pm

Euclides,

Try oGet:keyDown( nKey ) instead.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Euclides » Sat Dec 06, 2008 11:27 am

James.
oGet:keyDown( nKey ) has no effect.
To to simulate the "Enter" key I must use:
REDEFINE BUTTON ID 24 OF oDlg1 ACTION ( oGet[nX]:SetFocus(), __Keyboard(chr(VK_RETURN)))

Regards, Euclides
User avatar
Euclides
 
Posts: 156
Joined: Wed Mar 28, 2007 1:19 pm

Postby James Bott » Sat Dec 06, 2008 2:42 pm

Euclides,

The simple solution is to define the numeric field as character:

nNr:="000.00"

Then convert it to a number afterwards.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Euclides » Mon Dec 08, 2008 10:13 am

Yes James.
I did it this weekend. I intended to use the TGET methods to do the job.
I almost had to do a separate routine for each field.
Thanks & Regards.
Euclides
User avatar
Euclides
 
Posts: 156
Joined: Wed Mar 28, 2007 1:19 pm

Postby James Bott » Mon Dec 08, 2008 12:58 pm

Euclides,

I'm not sure what you did. You only needed to change the intitialization of the numeric vars to character from 0, then convert them to numeric when you save the data. You only need one extra line of code for each numeric var, e.g.

nAmount := val( cAmount )

It is a little extra code, but you don't need a routine for each var.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Rochinha » Mon Dec 08, 2008 2:56 pm

Euclides,

I found this sample in SAMPLES:

Code: Select all  Expand view
// A 'virtual' Keyboard sample

#include "Fivewin.ch"
static oWnd
Function Main()
    local hDLL := LoadLibrary( "bwcc32.dll" )   // NUEVO!
    SET RESOURCES TO "KBSIM_32.DLL"
    BWCCRegister( GetResources() )

        DEFINE WINDOW oWnd TITLE "Prueba de Gets"
        ACTIVATE WINDOW oWnd MAXIMIZED ON INIT Dialogo1()

        SET RESOURCES TO
       
        #ifndef __CLIPPER__
           FreeLibrary( hDLL )
        #endif   

return NIL

Function Dialogo1()
        Local oBtn1, oBtn2, oGet1, cVar, oDlg
        cVar := "  -    -  "
        DEFINE DIALOG oDlg NAME "KEYB"
       
        REDEFINE GET oGet1 VAR cVar ID 143 OF oDlg PICTURE "AX-9999-AA"
        REDEFINE BUTTON oBtn1 ID 101 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("1")))
        REDEFINE BUTTON oBtn1 ID 102 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("2")))
        REDEFINE BUTTON oBtn1 ID 103 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("3")))
        REDEFINE BUTTON oBtn1 ID 104 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("4")))
        REDEFINE BUTTON oBtn1 ID 105 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("5")))
        REDEFINE BUTTON oBtn1 ID 106 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("6")))
        REDEFINE BUTTON oBtn1 ID 107 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("7")))
        REDEFINE BUTTON oBtn1 ID 108 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("8")))
        REDEFINE BUTTON oBtn1 ID 109 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("9")))
        REDEFINE BUTTON oBtn1 ID 110 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("0")))
        REDEFINE BUTTON oBtn1 ID 111 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("Q")))
        REDEFINE BUTTON oBtn1 ID 112 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("W")))
        REDEFINE BUTTON oBtn1 ID 113 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("E")))
        REDEFINE BUTTON oBtn1 ID 114 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("R")))
        REDEFINE BUTTON oBtn1 ID 115 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("T")))
        REDEFINE BUTTON oBtn1 ID 116 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("Y")))
        REDEFINE BUTTON oBtn1 ID 117 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("U")))
        REDEFINE BUTTON oBtn1 ID 118 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("I")))
        REDEFINE BUTTON oBtn1 ID 119 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("O")))
        REDEFINE BUTTON oBtn1 ID 120 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("P")))
        REDEFINE BUTTON oBtn1 ID 121 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("A")))
        REDEFINE BUTTON oBtn1 ID 122 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("S")))
        REDEFINE BUTTON oBtn1 ID 123 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("D")))
        REDEFINE BUTTON oBtn1 ID 124 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("F")))
        REDEFINE BUTTON oBtn1 ID 125 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("G")))
        REDEFINE BUTTON oBtn1 ID 126 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("H")))
        REDEFINE BUTTON oBtn1 ID 127 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("J")))
        REDEFINE BUTTON oBtn1 ID 128 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("K")))
        REDEFINE BUTTON oBtn1 ID 129 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("L")))
        REDEFINE BUTTON oBtn1 ID 130 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("Z")))
        REDEFINE BUTTON oBtn1 ID 131 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("X")))
        REDEFINE BUTTON oBtn1 ID 132 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("C")))
        REDEFINE BUTTON oBtn1 ID 133 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("V")))
        REDEFINE BUTTON oBtn1 ID 134 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("B")))
        REDEFINE BUTTON oBtn1 ID 135 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("N")))
        REDEFINE BUTTON oBtn1 ID 136 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC("M")))
        REDEFINE BUTTON oBtn1 ID 137 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyDown(VK_UP))
        REDEFINE BUTTON oBtn1 ID 138 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyDown(VK_DOWN))
        REDEFINE BUTTON oBtn1 ID 139 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyDown(VK_LEFT))
        REDEFINE BUTTON oBtn1 ID 140 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyDown(VK_RIGHT))
        REDEFINE BUTTON oBtn1 ID 141 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(ASC(" ")))
        REDEFINE BUTTON oBtn1 ID 142 OF oDlg ACTION (MsgBeep(),;
                                                     oGet1:SetFocus(.t.),;
                                                     oGet1:KeyChar(VK_BACK))
       
        ACTIVATE DIALOG oDlg CENTERED
return NIL

#ifdef __XPP__
*   32 bits Alaska XPP source code here...
    procedure AppSys

    return
#else
*   16 bits Clipper source code here...
#endif

#ifndef __CLIPPER__
**   32 bits Alaska XPP source code here...
       DLL32 FUNCTION BWCCRegister( hInst AS LONG  ) AS LONG PASCAL LIB "BWCC32.DLL"
#else
**   16 bits Clipper source code here...
#endif


http://www.5volution.com/downloads/keybsim2.zip
Rochinha
 
Posts: 310
Joined: Sun Jan 08, 2006 10:09 pm
Location: Brasil - Sao Paulo

Postby Euclides » Tue Dec 09, 2008 11:09 am

Hi Rochinha,
I started my project from KEYBSIM.PRG from the SAMPLES folder.
My problem was with numeric fields with decimal places so i built specific routines to treat character by character and some checkings. (do not let the user type twice a decimal point, etc)
Thanks & Regards
Euclides
User avatar
Euclides
 
Posts: 156
Joined: Wed Mar 28, 2007 1:19 pm

Postby James Bott » Tue Dec 09, 2008 3:33 pm

Euclides,

>My problem was with numeric fields with decimal places so i built specific routines to treat character by character and some checkings. (do not let the user type twice a decimal point, etc)

You don't need all that if you simply use a numeric picture clause and define the default variable as character.

cVar := "000.00"

REDEFINE GET...PICTURE "E 999.99"

This will prevent two decimals, characters, etc.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Virtual Keyboard

Postby George » Wed Jul 08, 2009 12:38 am

Euclides,

Can you share with us your experience and how you resolved the Virtual Keyboard NUMERIC problem?

Regards,

George
George
 
Posts: 725
Joined: Tue Oct 18, 2005 6:49 pm

Re: Virtual Keyboard

Postby Gross » Mon Nov 07, 2016 4:35 pm

I have the same problem.
Does anyone have a solution?

Thank you Mannfrerd
Manfred Groß
Gross
 
Posts: 41
Joined: Sat Mar 09, 2013 8:17 am
Location: Germany Kassel

Re: Virtual Keyboard

Postby Antonio Linares » Mon Nov 07, 2016 5:17 pm

Manfred,

Could you please provide a small self contained example ? thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Virtual Keyboard

Postby Gross » Mon Nov 07, 2016 9:31 pm

Hi Antonio,
please test

Code: Select all  Expand view

#INCLUDE "fivewin.CH"
#INCLUDE "HbClass.CH"


// ---------------------------------------------------------------------------------------------
function Main()
// ---------------------------------------------------------------------------------------------
    LOCAL cNr := space(10)
    LOCAL nNr := 0
    LOCAL oDlg, nx
    LOCAL oGet := {NIL,NIL}



    SET EXACT OFF
    SET DELETE ON
    SET DATE GERMAN
    SET CONFIRM OFF // ON
    SET TYPEAHEAD TO 100
    SET EXCLUSIV OFF
    SET DECIMALS TO 2
    SET EPOCH TO year( date() ) - 80
    SET CENTURY ON


    DEFINE DIALOG oDlg TITLE "Test Num Get" SIZE 300, 300  PIXEL TRUEPIXEL


    @ 30, 8    SAY "Get 1"              PIXEL OF oDlg
    @ 30, 160  GET oGet[1] VAR cNr      PIXEL OF oDlg  SIZE 100, 25
    oGet[1]:bGotFocus:={|| nX:=1 }

    @ 60, 8    SAY "Get 2"              PIXEL OF oDlg
    @ 60, 160  GET oGet[2] VAR nNr      PIXEL OF oDlg  SIZE 100, 25 PICTURE "@E 999.99"
    oGet[2]:bGotFocus:={|| nX:=2 }

    @ 100, 50   BUTTON "Get 1"  OF oDlg size 50,30  PIXEL ;
             ACTION ( SetFocus(oGet[nX]:hWnd), oGet[nX]:KeyChar(asc("0")))
    @ 100, 120  BUTTON "Get 2" OF oDlg size 50,30  PIXEL ;
             ACTION ( SetFocus(oGet[nX]:hWnd), oGet[nX]:KeyChar(asc("1")))

    ACTIVATE DIALOG oDlg CENTER


return NIL
 


Manfred
Manfred Groß
Gross
 
Posts: 41
Joined: Sat Mar 09, 2013 8:17 am
Location: Germany Kassel

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 89 guests