Input Text Box

Hi,

Suppose I want my game to give the ability
to enter the player name in an input text box,
is it possible to do so with SDL ?–
Giuseppe Torelli

Yes, it sure is, but you are gonna have to either build your own GUI, or
download some pre-made ones. I made one for my game, I found all the
libraries out there to be a bit too bulky for my purposes.

Once you got some sort of GUI built, it’s only a matter of reading in
the keyboard map.On Thu, 2004-02-05 at 02:21, torelli at szn.it wrote:

Hi,

Suppose I want my game to give the ability
to enter the player name in an input text box,
is it possible to do so with SDL ?

Quoth torelli at szn.it , on Sat 31 Jan 2004:

Hi,

Suppose I want my game to give the ability
to enter the player name in an input text box,
is it possible to do so with SDL ?

This is related to the FAQ about SDL GUIs:
http://www.libsdl.org/faq.php?action=listentries&category=2#18

In short: yes, you can draw whatever you want, including a text box,
and you can process keyboard events to give it whatever behavior you
desire. Yes, there exist libraries that will (try to) do this for
you; they are often referenced on the SDL auxiliary libraries page
http://www.libsdl.org/libraries.php. It may or may not be possible
to use other GUI toolkits with SDL windows.


Giuseppe Torelli

—> Drake Wilson
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040205/9c650eb9/attachment.pgp

if your doing buffered input, you probly want to be listening to the keydown
events instead of searching through the keystate array.

also a friendly hint, enable key repeat! (i just figured this out not too
long ago, helps alot for text entry).

and heres another neat tip, to draw a good looking text box, draw a
rectangle in one color, then draw a 1 pixel border of a dark color on the
left and top of the box, and draw a 1 pixel border of a light color on the
right and bottom of the box. It will look 3D like all decent GUI’s look (:> ----- Original Message -----

From: starmars@enunu.com (Michael Cabral)
To:
Sent: Thursday, February 05, 2004 12:26 AM
Subject: Re: [SDL] Input Text Box

On Thu, 2004-02-05 at 02:21, torelli at szn.it wrote:

Hi,

Suppose I want my game to give the ability
to enter the player name in an input text box,
is it possible to do so with SDL ?

Yes, it sure is, but you are gonna have to either build your own GUI, or
download some pre-made ones. I made one for my game, I found all the
libraries out there to be a bit too bulky for my purposes.

Once you got some sort of GUI built, it’s only a matter of reading in
the keyboard map.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Alle Thursday 05 February 2004 10:07, Alan Wolfe ha scritto:

and heres another neat tip, to draw a good looking text box, draw a
rectangle in one color, then draw a 1 pixel border of a dark color on the
left and top of the box, and draw a 1 pixel border of a light color on the
right and bottom of the box. It will look 3D like all decent GUI’s look (:

So this way I can have an input text box without using any
additional GUI right ? I only have to draw the character
in the text box corresponding to the pressed key, right ?

Thanks to all who kindly reply me.–
Giuseppe Torelli

Thanks for the help with compiling SDL on cygwin; I’m sorry to say that I’m still havaing trouble compiling other libraries or applications that use SDL due to some problem with the configure scripts (the same problem for every one):

checking for a BSD compatible install… /usr/bin/install -c
: not found
checking for sdl-config… /usr/local/bin/sdl-config
checking for SDL - version >= 1.2.4… no
*** Could not run SDL test program, checking why…
*** The test program compiled, but did not run. This usually means
*** that the run-time linker is not finding SDL or finding the wrong
*** version of SDL. If it is not finding SDL, you’ll need to set your
*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point
*** to the installed location Also, make sure you have run ldconfig if that
*** is required on your system***
*** If you have an old version installed, it is best to remove it, although
*** you may also be able to get things to work by modifying LD_LIBRARY_PATH
configure: error: *** SDL version 1.2.4 not found!

I’ve tried setting the LD_LIBRARY_PATH variable to no avail.

Thanks,
Brandon

First enable the unicode translation of the keyboard events with
SDL_EnableUNICODE(1). Then maybe enable key repeating with
SDL_EnableKeyRepeat(delay, interval).
Then do SDL_PollEvent and check for keydown events. In the manpage of
SDL_keysym you can see an example for translating the unicode keys to
ASCII. I use this code:

if((event.key.keysym.unicode & 0xFF80) == 0)
string[strlen(string)] = event.key.keysym.unicode & 0x7F;

I’m not sure if this is the best way, but it certainly works well for
ASCII characters.

Bernhard

torelli at szn.it wrote:> Hi,

Suppose I want my game to give the ability
to enter the player name in an input text box,
is it possible to do so with SDL ?

do you draw the lines using your own draw-line routine or do you draw
rectangles with a with of 1

maybe something like SDL_DrawLine() should be added when we’ve got a
opengl backend (->hardware support).
i think even some backends now support this things.

Alan Wolfe wrote:>if your doing buffered input, you probly want to be listening to the keydown

events instead of searching through the keystate array.

also a friendly hint, enable key repeat! (i just figured this out not too
long ago, helps alot for text entry).

and heres another neat tip, to draw a good looking text box, draw a
rectangle in one color, then draw a 1 pixel border of a dark color on the
left and top of the box, and draw a 1 pixel border of a light color on the
right and bottom of the box. It will look 3D like all decent GUI’s look (:

----- Original Message -----
From: “MC”
To:
Sent: Thursday, February 05, 2004 12:26 AM
Subject: Re: [SDL] Input Text Box

On Thu, 2004-02-05 at 02:21, torelli at szn.it wrote:

Hi,

Suppose I want my game to give the ability
to enter the player name in an input text box,
is it possible to do so with SDL ?

Yes, it sure is, but you are gonna have to either build your own GUI, or
download some pre-made ones. I made one for my game, I found all the
libraries out there to be a bit too bulky for my purposes.

Once you got some sort of GUI built, it’s only a matter of reading in
the keyboard map.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Florian Hufsky wrote:

do you draw the lines using your own draw-line routine or do you draw
rectangles with a with of 1

maybe something like SDL_DrawLine() should be added when we’ve got a
opengl backend (->hardware support).
i think even some backends now support this things.

That was already discussed :
http://www.libsdl.org/pipermail/sdl/2003-October/057090.html

Sure, adding line capability to SDL would be nice, but there are some
pitfalls to avoid (AA lines support ?).
Maybe we could put together a patch for that. The patch to the glSDL
backend would be trivial (GL_LINES), for X11 it’s probably easy
(XDrawLine) but it would need more platforms than that to be
interesting. We’d also need some bresenham fallback…

What do people think about a line API ? Sam ?

Stephane

Quoth Stephane Marchesin <stephane.marchesin at wanadoo.fr>, on Wed 04 Feb 2004:

What do people think about a line API ? Sam ?

And this couldn’t be put in SDL_draw http://sdl-draw.sourceforge.net/ why?

Stephane

—> Drake Wilson
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040209/c19e72d6/attachment.pgp

Drake Wilson wrote:

Quoth Stephane Marchesin <@Stephane_Marchesin>, on Wed 04 Feb 2004:

What do people think about a line API ? Sam ?

And this couldn’t be put in SDL_draw http://sdl-draw.sourceforge.net/ why?

Because if you want hardware accelerated support for any kind of
graphics, you need platform-dependent code. So you must touch the misc.
backends to add, for example, the hardware accelerated line function for
each platform that supports it.
Of course, you can always use software emulation, but the current trend
with graphics acceleration is that everything is hosted on the video
card (surfaces, textures, buffers, shading functions…) so using
software emulation will eat the precious cpu-to-video bandwidth.

Stephane

What do people think about a line API ? Sam ?

This was discussed a long time ago, and we decided that since line drawing
APIs vary so widely between platforms and since most applications work with
surfaces, and/or don’t need high performance line drawing, that we would
leave line drawing to software implementations.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment