Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (dr_panther, 7th_zorro), 1,203 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Cursor blinking? #483984
08/23/21 06:10
08/23/21 06:10
Joined: Jan 2012
Posts: 108
G
gamers Offline OP
Member
gamers  Offline OP
Member
G

Joined: Jan 2012
Posts: 108
Hello there,

With the code I shared below, I want the participant to enter a 3-digit value in a text box. When the user clicks with the mouse to enter a value, the cursor I marked with the yellow arrow in the text box flashes/blinking. How can I remove this blinking cursor from being displayed?

Thank you for your help.

Blinking cursor figure


Code
BMAP* pointer_tga = "pointer.tga";
STRING* name_str = "Write Here!";


function input_name(); 

TEXT* name_txt = 
{
       pos_x = 320;
       pos_y = 70;
       layer = 11;
       font = "Calibri#52";   
       string(name_str);
       flags = SHOW;
}

PANEL* input_pan = 
{
       bmap = "textbox.png";
       pos_x = 280;
       pos_y = 40;
       layer = 10;
       on_click = input_name;
       flags = SHOW ;
}

function input_name()
{
       while (mouse_left) {wait (1);} 
       var filehandle;
       
    
       str_cpy(name_str, "   "); 
       inkey(name_str); 
       
       while(key_enter)
       {
       	wait(1);
       	filehandle = file_open_write("save_log.txt"); 
	       file_str_write(filehandle, name_str); 
	       file_close(filehandle);
       }
	       
	       
	    
}

BMAP* pointer_tga = "fareORJ.tga";
function mouse_startup()
{  
	mouse_mode = 2;
	mouse_map = pointer_tga;
	while (1)
	{  
		vec_set(mouse_pos, mouse_cursor);
		wait(1);
	}
}



Last edited by gamers; 08/23/21 06:12.
Re: Cursor blinking? [Re: gamers] #483989
08/23/21 19:59
08/23/21 19:59
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
I did not do much with inkey, If nobody got a better solution i have one idea.

You could use an own (bitmap-) font.
In this font you leave char 127 ( _ ) empty. This way it wont be displayed i guess.
[Linked Image]

greets

Last edited by rayp; 08/23/21 21:15.

Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: Cursor blinking? [Re: rayp] #483992
08/24/21 06:40
08/24/21 06:40
Joined: Jan 2012
Posts: 108
G
gamers Offline OP
Member
gamers  Offline OP
Member
G

Joined: Jan 2012
Posts: 108
Hi rayp,

Thanks for your response. Due to the functions I use, I need to do this using inkey.
I will try the method you suggested for different situations.

Kind regards

Re: Cursor blinking? [Re: gamers] #483993
08/24/21 10:27
08/24/21 10:27
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
You can still do it with inkey. Just use a Font without the ( _ ) Char and it wont display while using inkey. I dont know If there is another way to hide the Cursor.

Simply use a Bitmap Font in your Text def instead a truetype Font.
Code
TEXT* name_txt = 
{
       pos_x = 320;
       pos_y = 70;
       layer = 11;
       font = "Calibri#52";   // use bitmap font here, instead of true type
       string(name_str);
       flags = SHOW;
}


edit:
Example of a bitmap font, i already removed the ( _ ) char:
[Linked Image]
Code
FONT* example_tga = "font.tga"; // the example file above
TEXT* name_txt = 
{
       pos_x = 320;
       pos_y = 70;
       layer = 11;
       font = example_tga;
       string(name_str);
       flags = SHOW;
}

This way (i guess at least) the ( _ ) char wont be displayed when using inkey.

Greets

Last edited by rayp; 08/24/21 19:51.

Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: Cursor blinking? [Re: rayp] #483995
08/25/21 08:34
08/25/21 08:34
Joined: Jan 2012
Posts: 108
G
gamers Offline OP
Member
gamers  Offline OP
Member
G

Joined: Jan 2012
Posts: 108
Hello rayp,

Thank you for your interest. I will try this code as soon as possible. I hope it will work. I wish you a nice day.

Re: Cursor blinking? [Re: gamers] #483996
08/25/21 08:52
08/25/21 08:52
Joined: Jan 2012
Posts: 108
G
gamers Offline OP
Member
gamers  Offline OP
Member
G

Joined: Jan 2012
Posts: 108
Hey rayp, thank you!

I tried the method you mentioned and yes it works, but when I use a bitmap font, I cannot use the WWRAP flag feature this time.

Re: Cursor blinking? [Re: gamers] #484000
08/25/21 20:31
08/25/21 20:31
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
Quote
thank you!

You are welcome, glad if i can help sometimes.

Thats 3d scripting...you do one thing then another thing wont work laugh
Almost nothing works the "easy way". Plus, acknex wont make it more easy...


edit: If you have predefined strings knowing they are too long you can use
Code
\n
to break the line.
Like:
Code
"This is the first line.\nThis is the second line"
With dynamic created strings (+unknown length) this is a way more complicated, of course.


Greets

Last edited by rayp; 08/25/21 20:58.

Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: Cursor blinking? [Re: gamers] #484003
08/25/21 22:57
08/25/21 22:57
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
Here you are...

Inkey with true type and WWRap and NO cursor wink

I added a void. This void checks the inkey-string every frame and feeds string2. String2 is displayed, no cursor.
The trick is to "inkey" into a invisible string, copy that string and display it, done in check_inkey-void. You need this void because inkey blocks.
And using inchar in a while works, but then you cant (without extra work) edit the string like you can with this inkey example below.

So finally:
Code
STRING* name_str = "Write Here!"; // still your main string, but not displayed anymore
STRING* string2  = "";            // inkey string buffer to display ( copy of name_str / frame )


function input_name(); 

TEXT* name_txt = 
{
       pos_x = 320;
       pos_y = 70;
       layer = 11;
       font = "Calibri#52";   
       string (string2);          // display the buffer string
       flags = SHOW;
}
PANEL* input_pan = 
{
       bmap = "textbox.png";
       pos_x = 280;
       pos_y = 40;
       layer = 10;
       on_click = input_name;
       flags = SHOW ;
}
// ---------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
void check_inkey(){
	wait (1); // cause when called inkey is not active already (or while(!inkey_active)wait(1);)
	while (inkey_active){		
	   str_cpy (string2, name_str);	// copy inkey-string to display-string
           wait (1);
	}
}
// ---------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
function input_name()
{
       while (mouse_left) wait (1);
       var filehandle;
       
    
       str_cpy(name_str, "   "); 
       check_inkey();
       inkey(name_str); 
       
       while(key_enter)
       {
          wait(1);
       	   filehandle = file_open_write("save_log.txt"); 
           if (filehandle){ // only use the handle if it is valid
	      file_str_write(filehandle, name_str); 
	      file_close(filehandle);
          }
       }
	       
	       
	    
}

BMAP* pointer_tga = "fareORJ.tga";
function mouse_startup()
{  
	mouse_mode = 2;
	mouse_map = pointer_tga;
	while (1)
	{  
	   vec_set(mouse_pos, mouse_cursor);
	   wait(1);
	}
}

Also added check for a valid file handle, btw. Always check handles before using them, if you dont like crashes.

greets


Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: Cursor blinking? [Re: rayp] #484005
08/26/21 06:05
08/26/21 06:05
Joined: Jan 2012
Posts: 108
G
gamers Offline OP
Member
gamers  Offline OP
Member
G

Joined: Jan 2012
Posts: 108
Hi rayp,

Thank you very much for your fruitful contribution laugh

Best regards,


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1