2 registered members (AndrewAMD, juanex),
1,247
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Cursor blinking?
#483984
08/23/21 06:10
08/23/21 06:10
|
Joined: Jan 2012
Posts: 108
gamers
OP
Member
|
OP
Member
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
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
X
|
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. 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: gamers]
#483993
08/24/21 10:27
08/24/21 10:27
|
Joined: Jul 2008
Posts: 2,107 Germany
rayp
X
|
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. 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:
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: gamers]
#484000
08/25/21 20:31
08/25/21 20:31
|
Joined: Jul 2008
Posts: 2,107 Germany
rayp
X
|
X
Joined: Jul 2008
Posts: 2,107
Germany
|
You are welcome, glad if i can help sometimes. Thats 3d scripting...you do one thing then another thing wont work 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 to break the line. Like: "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
X
|
X
Joined: Jul 2008
Posts: 2,107
Germany
|
Here you are... Inkey with true type and WWRap and NO cursor 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: 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
gamers
OP
Member
|
OP
Member
Joined: Jan 2012
Posts: 108
|
Hi rayp, Thank you very much for your fruitful contribution Best regards,
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|