BASIC

Author Topic: IMPUT$ (input$ in any device!)  (Read 6119 times)

Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1594
    • View Profile
    • AMpostata Website
IMPUT$ (input$ in any device!)
« on: 2011-Sep-19 »
This functions is the same as INPUT$ but it opens a virtual keyboard if target device has no keyboard.

Just call it as

Code: GLBasic [Select]
t$=imput$(Text$,x,y)

Where "text" is a text :) to be displayed behind the input cursor.

At run, it asumes the device has keyboard and a "standard" input cursor is displayed. If the user touchs the screen, it now thinks you have no keyboard and a virtual keyboard is shown in screen. Now you can type using mouse/toouchscreen and keyboard.

It has been tested with Android (no keyboard) and Pre2 (keyboard) and it works great. Too lazy for iOS with/out bluetooth keyboard.

Due to my current development method, it has been created for a virtual screen enviroment.

You have to create a 1024x640 (16:10 aspect) screen 1 with sprite id "my_screen". This screen will be scaled and drawn to fit (with aspect ratio locked) the current screen (it has been tested on 480x320, 1024x768, 800x480 and looks great!).

The keyboard creates a virtual screen 2 with sprite id keyb_keyboard, but is not needed anything by the user.

Also virtual screen 3 sprite id keyb_input is created for the input text zone (this has been aded a few minutes ago and has not been tested a lot).

Also the demo has a few working buttons created with ZONES library, so this demo is for ZONES lib, IMPUT$() and SCALE  =D

The whole libe has been updated to use gensprite() and genfont() so you dont have to worry more about sprites IDs. Notice you still have to create a virtual screen ID 1 as your main drawing screen. Virtual screens 2 and 3 are also created and discarded after use.

Keyboard zones are moved from 1-44 to 10001-10044, so it is unlikely they will overwrite your current zones.

Now the keyboard is hidden if the user click outside the keyboard. Much cooler now! :)



[attachment deleted by admin]
« Last Edit: 2011-Sep-20 by ampos »
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10697
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: IMPUT$ (input$ in any device!)
« Reply #1 on: 2011-Sep-19 »
please fix it to use GENSPRITE instead. It's easier to "plug into" an existing project, then.

[edit]
AWESOME WORK!

Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1594
    • View Profile
    • AMpostata Website
Re: IMPUT$ (input$ in any device!)
« Reply #2 on: 2011-Sep-19 »
Oh, I see. I will rewrite it tonite. Stay tuned!  =D
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Offline Minion

  • Mr. Polyvector
  • ***
  • Posts: 229
    • View Profile
Re: IMPUT$ (input$ in any device!)
« Reply #3 on: 2011-Sep-19 »
Its nice, I like it. But I have a problem with the space entry. Each time I click the space buttone it changes case, so if I enter 2 or more spaces it goes Upeper, then lower then upper then lower etc case.

Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1594
    • View Profile
    • AMpostata Website
Re: IMPUT$ (input$ in any device!)
« Reply #4 on: 2011-Sep-19 »
It is because I use it to write names of persons.

Just remove completly the cases 39 and 40.

I have just noted that this auto-case is not working in phisical keyboard :)
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Offline msx

  • Prof. Inline
  • *****
  • Posts: 773
    • View Profile
Re: IMPUT$ (input$ in any device!)
« Reply #5 on: 2011-Sep-19 »
 :nw: :nw:

Offline Nathan

  • Mr. Polyvector
  • ***
  • Posts: 116
    • View Profile
Re: IMPUT$ (input$ in any device!)
« Reply #6 on: 2011-Sep-19 »
Superb work there.   :good:

Offline Albert

  • Dr. Type
  • ****
  • Posts: 257
    • View Profile
    • Blog
Re: IMPUT$ (input$ in any device!)
« Reply #7 on: 2011-Sep-19 »
I like it. Should be add a Hide Keyboard button (or hide it if touch outside the keyboard)

Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1594
    • View Profile
    • AMpostata Website
Re: IMPUT$ (input$ in any device!)
« Reply #8 on: 2011-Sep-19 »
I like it. Should be add a Hide Keyboard button (or hide it if touch outside the keyboard)

Not bad idea to hide it.

It will be done.
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2613
    • View Profile
Re: IMPUT$ (input$ in any device!)
« Reply #9 on: 2011-Sep-19 »
This looks really good, well done!  =D
Cheers,

Ian.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration.”
(E. W. Dijkstra)

Offline blackway

  • Mr. Polyvector
  • ***
  • Posts: 186
    • View Profile
Re: IMPUT$ (input$ in any device!)
« Reply #10 on: 2011-Sep-19 »
Ampos, It's great !!!!!!
Thanks for share !!
I'll use it in my next game!  :good:
Cheers,

Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1594
    • View Profile
    • AMpostata Website
Re: IMPUT$ (input$ in any device!)
« Reply #11 on: 2011-Sep-20 »
Updated to use gensprite() and genfont() so they can be included in your proyect more easily.

Also it has been updated to hide the keyboard if the user clicks outside the virtual keyboard. Much cooler now!

 :booze:
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Offline Hatonastick

  • Dr. Type
  • ****
  • Posts: 474
  • Amstrad CPC 6128
    • View Profile
Re: IMPUT$ (input$ in any device!)
« Reply #12 on: 2011-Nov-01 »
I love how this looks on my PC, however I can't get it to work properly on either of my Android devices.  It compiles, installs and runs.  However when you run the example the font is _tiny_.  At a guess I'd say around 2x2 pixels on the screen and it doesn't seem to matter whether I compile it for my phone (3" screen) or tablet (7" screen).  I've tried all sorts of changes but nothing seems to really impact on the size.  Both the 'small' font and the 'large' font seem to display as being the same size ie. tiny.  I'm guessing there's a scaling issue somewhere but I haven't spotted it thus far.

Has anyone had any luck getting this to work properly under Android?  I'd really like to use it. :)
Mat. 5: 14 - 16

Android: Toshiba Thrive Tablet (3.2), Samsung Galaxy Tab 2 (4.1.2).
Netbook: Samsung N150+ Netbook (Win 7 32-bit + Ubuntu 11.10).
Desktop: Intel i5 Desktop with NVIDIA GeForce GTX 460 (Win 8.1 64-bit).

Offline Mikele

  • Mc. Print
  • *
  • Posts: 28
    • View Profile
Re: IMPUT$ (input$ in any device!)
« Reply #13 on: 2011-Nov-01 »
[...]

Has anyone had any luck getting this to work properly under Android?  I'd really like to use it. :)

Hey, I had same problem. Try to change:

mpat$=GETCURRENTDIR$()+"media/"


to

mpat$="Media/"

In my case it does work.

M.

[EDIT] It's a "case sensitive" problem. I've changed line mpat$=GETCURRENTDIR$()+"Media/"  ("media" changed to "Media") and it does job as should.
« Last Edit: 2011-Nov-01 by Mikele »

Offline Hatonastick

  • Dr. Type
  • ****
  • Posts: 474
  • Amstrad CPC 6128
    • View Profile
Re: IMPUT$ (input$ in any device!)
« Reply #14 on: 2011-Nov-01 »
Whoops, yeah I somehow missed that bit.  You are right, that's all that needs to be changed and then it works perfectly.  :good:

Thanks!
Mat. 5: 14 - 16

Android: Toshiba Thrive Tablet (3.2), Samsung Galaxy Tab 2 (4.1.2).
Netbook: Samsung N150+ Netbook (Win 7 32-bit + Ubuntu 11.10).
Desktop: Intel i5 Desktop with NVIDIA GeForce GTX 460 (Win 8.1 64-bit).