AccueilAccueil  FAQFAQ  RechercherRechercher  S'enregistrerS'enregistrer  MembresMembres  Connexion  

Partagez | 
 

 Keyboard mobile et windows

Aller en bas 
AuteurMessage
Legends
Petit bavard
avatar

Messages : 55
Localisation : 28
Projet Actuel : Zakyro
jeu Android

MessageSujet: Keyboard mobile et windows   Dim 30 Sep 2018 - 23:54

Bonjour j'ai trouver un script pas mal pour ouvrir un keyboard sur pc et mobile

Tout les script
Code:
scr_keyfree_get_acu_string
// Returns a string composed of the accumulation of all the selected keys

if ( obj_keyfree_ctrl.keyfree_active ){

    return string(obj_keyfree_board.keyfree_acu_string);
}
else {

    return string("");
}

scr_keyfree_is_clicked
// Returns true or false if a key has been clicked

if ( obj_keyfree_ctrl.keyfree_active ){

    if ( obj_keyfree_board.key_selected )
        or ( obj_keyfree_board.key_delete_selected )
        or ( obj_keyfree_board.key_space_selected ){
    
        return true;
    }
    else {
    
        return false;
    }
}
else {

    return false;
}

scr_keyfree_keys
// Array of characters for the board
//
// argument0 = 0:set key positions; 1:letters; 2:numbers & characters
//

if ( argument0 = 1 ){
// Letters

    key_string = 0;

    key_string[0] = 'aA';
    key_string[1] = 'bB';
    key_string[2] = 'cC';
    key_string[3] = 'dD';
    key_string[4] = 'eE';
    key_string[5] = 'fF';
    key_string[6] = 'gG';
    key_string[7] = 'hH';
    key_string[8] = 'iI';
    key_string[9] = 'jJ';
    key_string[10] = 'kK';
    key_string[11] = 'lL';
    key_string[12] = 'mM';
    key_string[13] = 'nN';
    key_string[14] = 'oO';
    key_string[15] = 'pP';
    key_string[16] = 'qQ';
    key_string[17] = 'rR';
    key_string[18] = 'sS';
    key_string[19] = 'tT';
    key_string[20] = 'uU';
    key_string[21] = 'vV';
    key_string[22] = 'wW';
    key_string[23] = 'xX';
    key_string[24] = 'yY';
    key_string[25] = 'zZ';
}
else if ( argument0 = 2 ){
// Numbers & Characters

    key_string = 0;
    
    key_string[0] = '0';
    key_string[1] = '1';
    key_string[2] = '2';
    key_string[3] = '3';
    key_string[4] = '4';
    key_string[5] = '5';
    key_string[6] = '6';
    key_string[7] = '7';
    key_string[8] = '8';
    key_string[9] = '9';
    key_string[10] = '@';
    key_string[11] = '\' + chr(35);
    key_string[12] = '$';
    key_string[13] = '%';
    key_string[14] = '&';
    key_string[15] = '*';
    key_string[16] = '(';
    key_string[17] = ')';
    key_string[18] = '-';
    key_string[19] = '\';
    key_string[20] = '!';
    key_string[21] = ';';
    key_string[22] = ':';
    key_string[23] = chr(39);
    key_string[24] = chr(34);
    key_string[25] = '?';
    key_string[26] = '/';
    key_string[27] = ',';
    key_string[28] = '.';
}

key_count = array_length_1d(key_string);

key_border_right = floor(key_count/2);
key_border_left = floor(key_count/2) + 1;

scr_keyfree_load
// Loads the Board
//

with ( obj_keyfree_ctrl ){

    keyfree_active = true;

    keyfree_instance = instance_create(0,0,obj_keyfree_board);
    
    with ( keyfree_instance ){ depth = obj_keyfree_ctrl.keyfree_board_depth; } // Set the depth of the Board
}

scr_keyfree_close
// Closes the Board
//


with ( obj_keyfree_ctrl ){ keyfree_active = false; keyfree_instance = 0; }

with ( obj_keyfree_board ){ instance_destroy(); }

scr_keyfree_move_key
// Move keys from one side of the board to another, depending on its position

if (( key_x[key_border_right] + board_slide_count ) > ( board_center_h + ( key_w * 2 ) + ( board_size / 2 ))){
// Right Side

    key_x[key_border_right] = key_x[key_border_left] - key_w - key_separation;
    
    var border_right_change = key_border_right - 1;
    var border_left_change = key_border_left - 1;
    
    if ( border_right_change < 0 ){ border_right_change = key_count - 1 }
    if ( border_left_change < 0 ){ border_left_change = key_count - 1 }
    
    key_border_right = border_right_change;
    
    key_border_left = border_left_change;
}
else if (( key_x[key_border_left] + board_slide_count ) < ( board_center_h - ( key_w * 2 ) - ( board_size / 2 ))){
// Left Side

    key_x[key_border_left] = key_x[key_border_right] + key_w + key_separation;
    
    var border_right_change = key_border_right + 1;
    var border_left_change = key_border_left + 1;
    
    if ( border_right_change > ( key_count - 1 )){ border_right_change = 0; }
    if ( border_left_change > ( key_count - 1 )){ border_left_change = 0; }
    
    key_border_right = border_right_change;
    
    key_border_left = border_left_change;
}  

scr_keyfree_new_char
// Returns the last character selected if available

if ( obj_keyfree_ctrl.keyfree_active ){

    if ( obj_keyfree_board.key_selected_id != -1 ){
    
        // return obj_keyboard_freedom.key_string[obj_keyboard_freedom.key_selected_id];
        
        return obj_keyfree_board.key_selected_string;
    }
    else {
    
        return -1;
    }
}
else {

    return -1;
}

scr_keyfree_set_acu_string
// argument0 : variable value
//
// Sets the value for keyfree_acu_string which holds the accumulated contents of what has been written.
//
// The value is sent to obj_keyfree_ctrl instead of obj_keyfree_board in case obj_keyfree_board
// is not active. The value remains in obj_keyfree_ctrl until it is transfered to obj_keyfree_board
//

with ( obj_keyfree_ctrl ){ keyfree_acu_string_temp = argument0; }

scr_keyfree_startpos
// Refresh the starting position of every key block
//

for ( i=0; i<=key_count; i+=1 ){

    key_x[i] = ( board_center_h + (( key_w * i ) + ( key_separation * i )));
    
    key_y[i] = board_center_v;
    
    if ( i > floor(key_count/2) ){
    
        new_i = key_count - i;
    
        key_x[i] = ( board_center_h - (( key_w * new_i ) + ( key_separation * new_i )));
    }
}

Obj keyfree ctrl
Code:
obj_keyfree_ctrl
Create
keyfree_active = false;       // si true, l'instance de conseil existe, est affiché.

keyfree_debug_mode = true;   // si vrai, affiche les variables de débogage à l'écran.

keyfree_board_depth = -500;   // Définir la profondeur du tableau

keyfree_acu_string_temp = ""  // sring temporaire qui sera transféré à obj_keyfree_board
                                   // si changé. Il détient la valeur jusqu'à ce qu'il soit transféré.

Step
// NOTE: this is used to transfer the value to keyfree_acu_string in
//       obj_keyfree_board when the board is active

if (( keyfree_active ) and ( keyfree_acu_string_temp != "" )){

    var local_keyfree_acu_string_temp = keyfree_acu_string_temp;

    with ( keyfree_instance ){ keyfree_acu_string = local_keyfree_acu_string_temp; }
    
    keyfree_acu_string_temp = "";
}

Obj keyfree input
Code:
obj_keyfree_input
create
/// Input Box Init

keyfree_new_char = "";      // tiendra le dernier caractère sélectionné.

keyfree_input_text = "";    // Chaîne contenant tout le texte d'entrée.

keyfree_input_empty_text = "Name"; // Message that appears in input box if there is no text

keyfree_text_w = 0;         // string visual width, for use with marker

box_width = 400;            // width of the input box;
box_height = 75;            // height of the input box;

box_pos_x = room_width/2;   // x position of the input box
box_pos_y = 180;            // y position of the input box

// Box rectangle based on size and position variables
box_x1 = box_pos_x - box_width;
box_y1 = box_pos_y;
box_x2 = box_pos_x + box_width;
box_y2 = box_y1 + box_height;

// Limits the max amount of text that the input will accept
text_limit = 10;

/// Marker Init

marker_height = 50;

marker_width = 5;

marker_buffer = 4;  // Space between last character and the marker.

// Marker initial position.
marker_y1 = (( box_pos_y + ( box_height / 2 )) - ( marker_height / 2 ));
marker_y2 = ( marker_y1 + marker_height );

marker_visible = false; // Marker initial visibility for blinking.

alarm[0] = room_speed; // Marker blinking.

alarm[0]
/// Marker Blinking

if ( marker_visible ){

    marker_visible = false;
}
else {

    marker_visible = true;
}

alarm[0] = room_speed;

Step
/// Detect Text Change ( Keyboard Freedom )

if ( obj_keyfree_ctrl.keyfree_active ){

    if ( scr_keyfree_is_clicked() ){
        
        keyfree_new_char = scr_keyfree_new_char(); // Get latest character selected.
        
        keyfree_input_text = scr_keyfree_get_acu_string(); // Gets all the accumulated text entered since activation
        
        // Text limit process
        if ( string_length(keyfree_input_text) > text_limit ){
            
            keyfree_input_text = string_copy(keyfree_input_text,1,text_limit);
            
            scr_keyfree_set_acu_string(keyfree_input_text); // After limiting the text, send it back to the board
        }
        
        draw_set_font(font_input); // set font to get width properly
        
        keyfree_text_w = string_width(keyfree_input_text);
        
        // Reset Marker
        marker_visible = true;
        alarm[0] = -1;
        alarm[0] = room_speed;
    }
}
Glob Left Release
/// Open Keyboard

if ( !obj_keyfree_ctrl.keyfree_active ){

    if ( mouse_x > box_x1 and mouse_x < box_x2 ){
    
        if ( mouse_y > box_y1 and mouse_y < box_y2 ){
        
            scr_keyfree_load();
            
            scr_keyfree_set_acu_string(keyfree_input_text);
        }
    }
}
Draw
/// Draw Input Box

draw_set_color(c_gray);

draw_rectangle(box_x1+1,box_y1+1,box_x2-1,box_y2-1,false);

draw_set_color(c_white);

draw_line_width(box_x1,box_y1+2,box_x2,box_y1+2,3);     // top line

draw_line_width(box_x1+1,box_y1,box_x1+1,box_y2,3);     // left line

draw_line_width(box_x1-1,box_y2-1,box_x2-1,box_y2-1,3); // bot line

draw_line_width(box_x2,box_y1,box_x2,box_y2,3);         // right line

/// Draw Keyboard Text

draw_set_font(font_input);

draw_set_colour(c_white);

draw_set_valign(fa_middle);
draw_set_halign(fa_center);

draw_text_transformed(box_pos_x,box_pos_y+(box_height/2),string(keyfree_input_text),1,1,0);

if (( !obj_keyfree_ctrl.keyfree_active ) and ( keyfree_input_text == "" )){

    draw_text_transformed(box_pos_x,box_pos_y+(box_height/2),string(keyfree_input_empty_text),1,1,0);
}
/// Draw Marker

if ( obj_keyfree_ctrl.keyfree_active ){

    if ( marker_visible ){
    
        var marker_x = box_pos_x + (( keyfree_text_w / 2 ));
        
        draw_set_color(c_black);
        
        // Marker
        draw_line_width(marker_x+marker_buffer,marker_y1,marker_x+marker_buffer,marker_y2,marker_width);
    }
}

Obj keyfree board
Code:
obj_keyfree_board
Create
/// Board Init

board_size = room_width + 100;      // Defines de borders of the Board

board_center_h = room_width / 2;    // Board Center Horizontal

board_center_v = 380;               // Board Center Vertical

board_slide_active = false;         // Holds weather the Character Boads is sliding or not

board_slide_active_prev = false;    // Helps determine if sliding changed from previous loop

board_slide_start = false;          // True only the first loop the Slide starts

board_slide_center = 0;             // Works like an anchor to determine where the slide starts on each loop

board_slide_count = 0;              // Distance the slide moves from board_slide_center on each loop

board_slide_auto_count = 0;         // Holds the speed of the slide to use it when the slide finishes for auto slide

board_slide_auto_dir = 0;           // Holds the direction of the slide

board_slide_auto_running = false;   // True if the Board is auto sliding

board_slide_auto_quot = 0.2;        // Ammount reduced from the auto slide on each looop to stop it

board_slide_auto_max = 30;          // Maximum speed for the auto slide

board_slide_buffer = 8;             // Distance of the manual slide before the Board actually starts moving

board_grab_buffer = 30;             // Works as an extra space to grab the Board for sliding

board_backspace_close = true;       // Sets if the board can be closed with the Backspace Key

/// Keys Init

/*/ Key Characters /*/

    key_char_1 = 1; // 1:letters; 2:numbers & characters.

    scr_keyfree_keys(key_char_1); // (1): script loads the characters.

    
/*/ Key Auto Adjust Size /*/

    key_size_adjust_auto = true; // true: auto determines the size of each letter block.
    
    key_size_adjust_keys = 10; // max ammount of keys in screen. Used for auto adjust.
    
    key_size_adjust_screen_size = room_width; // the size of the are to use for auto adjust.
    
    if ( key_size_adjust_auto ){
    
        key_w = floor( key_size_adjust_screen_size / key_size_adjust_keys ); // key width. ( auto )
        key_h = key_w;
    }
    else {
    
        key_w = 100; // key width.
        key_h = 100; // key height.
    }

    
/*/ Key Background /*/

    key_border_size = 3;             // border size for each character block.
    key_separation = 3;              // separation size between each character block.
    key_border_color = c_dkgray;     // block border color.
    key_bg_color = c_black;          // block background color.
    key_sel_border_color = c_dkgray; // selected block border color.
    key_sel_bg_color = c_white;      // selected block background color.
    
    
/*/ Key Font /*/

    key_font = font_board;        // block font.
    key_font_color = c_white;     // block font color.
    key_sel_font_color = c_black; // selected block font color.


/*/ Key Initial Position /*/

    scr_keyfree_startpos(); // (0): initial position for all the character blocks.
    

/*/ Key Selected Vars /*/

    key_selected_open = true;   // if true, the keys are open for selection.
    key_selected = false;       // if true, a key has been selected.
    key_selected_x = 0;         // x coordinate for selected key.
    key_selected_y = 0;         // y coordinate for selected key.
    key_selected_id = -1;       // id value for selected key.
    key_selected_string = "";   // string value for selected key.
    key_sel_show_open = true;   // if true, the selected key is available to be drawn
    key_selected_show = false;  // if true, the selected key is draw on screen


/// Key Background Init
// ----------------------------
// This code creates a surface for the background of each block, then turns it
// into a sprite that is reused for every key block.

/*/ Board Background /*/

    surf = surface_create(key_w, key_h);
    
    surface_set_target(surf);
        
        // create border
        draw_set_color(key_border_color);
        draw_rectangle(0,0,key_w,key_h,false);
        
        // create block
        draw_set_color(key_bg_color);
        draw_rectangle(key_border_size,key_border_size,( key_w - (key_border_size + 1)),( key_h - (key_border_size + 1)),false);
    
    surface_reset_target();
    
    // sprite created from surface
    key_bg = sprite_create_from_surface(surf, 0, 0, key_w, key_h, false, false, (key_w/2), (key_h/2));
    
    surface_free(surf);

    
/*/ Selected Background /*/

    surf = surface_create(key_w, key_h);
    
    surface_set_target(surf);
        
        // create border
        draw_set_color(key_sel_border_color);
        draw_rectangle(0,0,key_w,key_h,false);
        
        // create block
        draw_set_color(key_sel_bg_color);
        draw_rectangle(key_border_size,key_border_size,( key_w - (key_border_size + 1)),( key_h - (key_border_size + 1)),false);
    
    surface_reset_target();
    
    // sprite created from surface
    key_sel_bg = sprite_create_from_surface(surf, 0, 0, key_w, key_h, false, false, (key_w/2), (key_h/2));
    
    surface_free(surf);


/// Action Buttons Init
// -----------------------------
// This code establishes the size and clickable area of each key.
// I don't recommend changing this page unless you know exactly how it works.
// All the values are created based on settings from other scripts.

key_action_open = true; // if true, an action button can be pressed

key_action_w = key_w;
key_action_h = key_h;

// Space Key
key_space_x = board_center_h;
key_space_y = board_center_v + key_h + key_separation + board_grab_buffer;
key_space_sel_x1 = key_space_x - ( key_w / 2 );
key_space_sel_x2 = key_space_x + ( key_w / 2 );
key_space_sel_y1 = key_space_y - ( key_w / 2 );
key_space_sel_y2 = key_space_y + ( key_w / 2 );

// Delete Key
key_delete_x = board_center_h + ( key_action_w + key_separation );
key_delete_y = board_center_v + key_h + key_separation + board_grab_buffer;
key_delete_sel_x1 = key_delete_x - ( key_w / 2 );
key_delete_sel_x2 = key_delete_x + ( key_w / 2 );
key_delete_sel_y1 = key_delete_y - ( key_w / 2 );
key_delete_sel_y2 = key_delete_y + ( key_w / 2 );

// Enter Key
key_enter_x = board_center_h + (( key_action_w + key_separation ) * 2);
key_enter_y = board_center_v + key_h + key_separation + board_grab_buffer;
key_enter_sel_x1 = key_enter_x - ( key_w / 2 );
key_enter_sel_x2 = key_enter_x + ( key_w / 2 );
key_enter_sel_y1 = key_enter_y - ( key_w / 2 );
key_enter_sel_y2 = key_enter_y + ( key_w / 2 );

// Shift Key
key_shift_x = board_center_h - ( key_action_w + key_separation );
key_shift_y = board_center_v + key_h + key_separation + board_grab_buffer;
key_shift_sel_x1 = key_shift_x - ( key_w / 2 );
key_shift_sel_x2 = key_shift_x + ( key_w / 2 );
key_shift_sel_y1 = key_shift_y - ( key_w / 2 );
key_shift_sel_y2 = key_shift_y + ( key_w / 2 );

// Chararcters Key
key_char_x = board_center_h - (( key_action_w + key_separation ) * 2);
key_char_y = board_center_v + key_h + key_separation + board_grab_buffer;
key_char_sel_x1 = key_char_x - ( key_w / 2 );
key_char_sel_x2 = key_char_x + ( key_w / 2 );
key_char_sel_y1 = key_char_y - ( key_w / 2 );
key_char_sel_y2 = key_char_y + ( key_w / 2 );


// Default Values

key_selected = false;        // if true, a key has been selected.

key_delete_selected = false; // if true, deleted key was selected

key_space_selected = false;  // if true, space key was selected

key_enter_selected = false;  // if true, enter key was selected

key_shift_selected = false;  // if true, shift key was selected

key_char_selected = false;   // if true, numbers & characters key was selected


// Special Button Status

key_delete_active = false;

key_space_active = false;

key_enter_active = false;

key_shift_active = false;

key_char_active = false;

/// Misc Variables Init
// -------------------------------
// Variables that must be created after

board_top_v = ( board_center_v - ( key_h / 2 )); // Sets the top position of the board.

board_bot_v = ( board_center_v + ( key_h / 2 )); // Sets the bottom position of the board.

mouse_x_prev = 0; // Used to determine the position of the pointer at the beggining of the loop.

keyfree_acu_string = ""; // It holds the accumulation of all selected keys.

key_cap_type = 1; // 1: Uppercase characters; 2: Lowercase characters;

device_mouse_dbclick_enable(false); // Options: Disables double click. Makes input faster.

Step
/// Reset Variables

    key_selected = false;        // if true, a key has been selected.
    
    key_delete_selected = false; // if true, deleted key was selected
    
    key_space_selected = false;  // if true, space key was selected
    
    key_enter_selected = false;  // if true, enter key was selected
    
    key_shift_selected = false;  // if true, shift key was selected
    
    key_char_selected = false;   // if true, numbers & characters key was selected

/// Detect Select Action ( Slide / Keys )

if ( mouse_check_button(mb_left) ){

    // Detect if auto slide is running when click occurs
    if (( board_slide_auto_count != 0 ) and ( board_slide_auto_count > board_slide_buffer )){ board_slide_auto_running = true; }

    // Detect if click is inside the character board
    if (( mouse_y > ( board_top_v - board_grab_buffer )) and ( mouse_y < ( board_bot_v + board_grab_buffer ))){
    
        board_slide_auto_count = 0;     // set auto slide speed to cero
        
        board_slide_active = true;      // Sets the start of the slide
        
        board_slide_start = true;       // Establishes this loop as the first of the slide process
    
        if ( key_selected_open ){    
            
            key_selected_x = mouse_x;   // x coodrdinate for selection
            key_selected_y = mouse_y;   // y coodrdinate for selection
        }
        
        key_action_open = false;        // Disabled Action buttons
    }
    else { board_slide_auto_count = 0;  /* set auto slide speed to cero */ }
    
    if ( key_action_open ){
        
        if ( key_delete_active and (( mouse_x > key_delete_sel_x1 and mouse_x < key_delete_sel_x2 ) and ( mouse_y > key_delete_sel_y1 and mouse_y < key_delete_sel_y2 ))){
        // Delete Key
        
            key_delete_selected = true;        
            key_delete_active = false;
        }
        else if ( key_space_active and (( mouse_x > key_space_sel_x1 and mouse_x < key_space_sel_x2 ) and ( mouse_y > key_space_sel_y1 and mouse_y < key_space_sel_y2 ))){
        // Space Key
        
            key_space_selected = true;        
            key_space_active = false;
        }
        else if ( key_enter_active and (( mouse_x > key_enter_sel_x1 and mouse_x < key_enter_sel_x2 ) and ( mouse_y > key_enter_sel_y1 and mouse_y < key_enter_sel_y2 ))){
        // Enter Key
        
            key_enter_selected = true;        
            key_enter_active = false;
        }
        else if (( key_char_1 == 1 ) and ( key_shift_active ) and (( mouse_x > key_shift_sel_x1 and mouse_x < key_shift_sel_x2 ) and ( mouse_y > key_shift_sel_y1 and mouse_y < key_shift_sel_y2 ))){
        // Shift Key
        
            key_shift_selected = true;        
            key_shift_active = false;
        }
        else if ( key_char_active and (( mouse_x > key_char_sel_x1 and mouse_x < key_char_sel_x2 ) and ( mouse_y > key_char_sel_y1 and mouse_y < key_char_sel_y2 ))){
        // Characters Key
        
            key_char_selected = true;        
            key_char_active = false;
        }
    }
    
    key_action_open = false;
}
else {
    
    key_selected_open = true;

    board_slide_active = false;
    
    key_delete_active = true;
    
    key_space_active = true;
    
    key_enter_active = true;
    
    key_shift_active = true;
    
    key_char_active = true;
    
    board_slide_start = false;    
}

/// Slide Control

if ( board_slide_active ){
// Slide

    if ( board_slide_active != board_slide_active_prev ){
    // first loop the slide is active
    
        board_slide_center = mouse_x;
    }
    
    board_slide_count = mouse_x - board_slide_center; // distance of the slide.
    
    if ( mouse_x_prev != 0 ){ board_slide_auto_count = abs( mouse_x - mouse_x_prev ); } // speed of the auto slide.
    
    if ( abs(board_slide_auto_count) > board_slide_auto_max ){ board_slide_auto_count = board_slide_auto_max; } // keep speed under the max allowed.
        
    if ( abs(board_slide_auto_count) > board_slide_buffer ){ key_selected_show = false; } // if sliding, do not show selected key
    
    // Establish the dorection of the auto slide
    if ( board_slide_count < 0 ){ board_slide_auto_count = abs(board_slide_auto_count) * -1; }
    else if ( board_slide_count > 0 ){ board_slide_auto_count = abs(board_slide_auto_count); }
    
    mouse_x_prev = mouse_x;
}
else {
        
    if ( board_slide_active != board_slide_active_prev ){
    // first loop the slide is inactive
    
        board_slide_count = mouse_x - board_slide_center;
        
        if ( abs(board_slide_count) > board_slide_buffer ){
        // Slide Over
        
            for ( i=0; i<key_count; i+=1 ){ key_x[i] = key_x[i] + board_slide_count; }
            
            scr_keyfree_move_key();
            
            key_selected = false;
            key_selected_id = -1;
            key_selected_string = "";
        }
        else if ( key_selected_id != -1 ) {
        // Key Selected
        
            if ( !board_slide_auto_running ){
            
                key_selected = true;
                key_selected_show = true;
                
                // key selected string
                if ( key_char_1 == 1 ){  var temp_string = string_copy(key_string[key_selected_id], key_cap_type, 1); }
                else { var temp_string = key_string[key_selected_id]; }
                
                keyfree_acu_string += string(temp_string); // acumulated string of all keys selected
            }
        }
    }
    
    board_slide_count = 0;
}

board_slide_active_prev = board_slide_active;

/// Key Position Change

if ( board_slide_start ){
                
    scr_keyfree_move_key(); // Move key blocks from side to side of the Board.
}

/// Key Selected

// Character Key
if ( !board_slide_auto_running and key_selected_open and board_slide_active ){

    for ( i=0; i<key_count; i+=1 ){
    
        if (( key_selected_x >= ( key_x[i] - ( key_w / 2 ))) and ( key_selected_x < ( key_x[i] + ( key_w / 2 )))){
        
            if ( key_char_1 == 1 ){  var temp_string = string_copy(key_string[i], key_cap_type, 1); }
            else { var temp_string = key_string[i]; }
        
            key_selected_id = i;
            
            key_selected_string = temp_string;
            
            key_selected_open = false;
            
            key_selected_show = true;
            
            exit;
        }
    }
}

if ( key_delete_selected ){
// Delete Key
    
    if ( string_length(keyfree_acu_string) > 0 ){
        
        var delete_count = 1;
        
        // if character to delete is #, delete 2 characters ( /# )
        if ( string_copy(keyfree_acu_string,string_length(keyfree_acu_string),1) == "#" ){ delete_count = 2; }
    
        keyfree_acu_string = string_copy(keyfree_acu_string, 1, ( string_length(keyfree_acu_string) - delete_count ));
    }
}
else if ( key_space_selected ){
// Spce Key
    
    if ( string_length(keyfree_acu_string) > 0 ){
        
        key_selected_string = " ";

        keyfree_acu_string = string(keyfree_acu_string) + string(key_selected_string);
    }
}
else if ( key_shift_selected ){
// Shift Key
    
    if ( key_cap_type == 1 ){ key_cap_type = 2; }
    else { key_cap_type = 1; }
}
else if ( key_char_selected ){
// Special Characters Key
    
    if ( key_char_1 == 1 ){ key_char_1 = 2; }
    else { key_char_1 = 1; }
    
    scr_keyfree_keys(key_char_1);
    
    scr_keyfree_startpos();
}
else if ( key_enter_selected ){
// Special Characters Key
    
    scr_keyfree_close();
}

/// Auto Slide Board

if ( !board_slide_active ){

    if ( abs(board_slide_auto_count) > 0 ){
    // Auto slide process
        
        for ( i=0; i<key_count; i+=1 ){ key_x[i] = key_x[i] + board_slide_auto_count; }
            
        scr_keyfree_move_key();
        
        if ( board_slide_auto_count > 0 ){
        // Right slide
        
            board_slide_auto_count -= board_slide_auto_quot;
            
            if ( board_slide_auto_count < 0 ){ board_slide_auto_count = 0; }
        }
        else {
        // Left slide
        
            board_slide_auto_count += board_slide_auto_quot;
            
            if ( board_slide_auto_count > 0 ){ board_slide_auto_count = 0; }
        }
    }
}

/// Click Released

if ( mouse_check_button_released(mb_left) ){
// When un-click...

    if ( key_selected and key_selected_show and key_cap_type = 2 ){ key_cap_type = 1; } // Restore Small Caps
    
    board_slide_auto_running = false;
    
    key_selected_show = false;
    
    key_action_open = true; // Enables Action buttons
    
    key_selected_i = -1;
        
    mouse_x_prev = 0; // Reset
}

Draw
/// Draw Board

    draw_set_font(key_font);
    
    draw_set_halign(fa_center);
    draw_set_valign(fa_middle);
    
    draw_set_color(c_white);
    
    var draw_board_slide_count = 0;
    
    if ( abs(board_slide_count) > board_slide_buffer ){ draw_board_slide_count = board_slide_count; }
    
    for ( i=0; i<key_count; i+=1 ){
    
        // Draw block. ( Background )
        
        var key_bg_x1 = key_x[i] + draw_board_slide_count - ( key_w / 2 );
        var key_bg_y1 = key_y[i] - ( key_h / 2 );
        var key_bg_x2 = key_bg_x1 + key_w;
        var key_bg_y2 = key_bg_y1 + key_h;
        
        draw_set_color(key_border_color);
        
        draw_rectangle(key_bg_x1, key_bg_y1, key_bg_x2, key_bg_y2, false);
        
        draw_set_color(key_bg_color);
        
        draw_rectangle(key_bg_x1+key_border_size, key_bg_y1+key_border_size, key_bg_x2-key_border_size, key_bg_y2-key_border_size, false);
        
        draw_set_color(key_font_color);
        
        if ( key_char_1 == 1 ){  var temp_string = string_copy(key_string[i], key_cap_type, 1); }
        else { var temp_string = key_string[i]; }
        
        draw_text(key_x[i]+draw_board_slide_count,key_y[i],string(temp_string)); // Draw character.
    }

/// Draw Action Buttons

    // Space Key  
    draw_set_color(key_border_color);
    draw_rectangle(key_space_sel_x1,key_space_sel_y1,key_space_sel_x2,key_space_sel_y2, false);
    draw_set_color(key_bg_color);
    draw_rectangle(key_space_sel_x1+key_border_size,key_space_sel_y1+key_border_size,key_space_sel_x2-key_border_size,key_space_sel_y2-key_border_size, false);
    draw_sprite_ext(spr_btn_space,-1,key_space_x,key_space_y,1,1,0,key_font_color,1);
    
    // Delete Key
    draw_set_color(key_border_color);
    draw_rectangle(key_delete_sel_x1,key_delete_sel_y1,key_delete_sel_x2,key_delete_sel_y2, false);
    draw_set_color(key_bg_color);
    draw_rectangle(key_delete_sel_x1+key_border_size,key_delete_sel_y1+key_border_size,key_delete_sel_x2-key_border_size,key_delete_sel_y2-key_border_size, false);
    draw_sprite_ext(spr_btn_delete,-1,key_delete_x,key_delete_y,1,1,0,key_font_color,1);
    
    // Enter Key
    draw_set_color(key_border_color);
    draw_rectangle(key_enter_sel_x1,key_enter_sel_y1,key_enter_sel_x2,key_enter_sel_y2, false);
    draw_set_color(key_bg_color);
    draw_rectangle(key_enter_sel_x1+key_border_size,key_enter_sel_y1+key_border_size,key_enter_sel_x2-key_border_size,key_enter_sel_y2-key_border_size, false);
    draw_sprite_ext(spr_btn_enter,-1,key_enter_x,key_enter_y,1,1,0,key_font_color,1);
    
    // Shift Key
    draw_set_color(key_border_color);
    draw_rectangle(key_shift_sel_x1,key_shift_sel_y1,key_shift_sel_x2,key_shift_sel_y2, false);
    draw_set_color(key_bg_color);
    draw_rectangle(key_shift_sel_x1+key_border_size,key_shift_sel_y1+key_border_size,key_shift_sel_x2-key_border_size,key_shift_sel_y2-key_border_size, false);
    draw_sprite_ext(spr_btn_shift,-1,key_shift_x,key_shift_y,1,1,0,key_font_color,1);
    
    if ( key_char_1 == 1 ){ spite_chars = spr_btn_chars; } else { spite_chars = spr_btn_letters; }
    
    // Special Characters Key
    draw_set_color(key_border_color);
    draw_rectangle(key_char_sel_x1,key_char_sel_y1,key_char_sel_x2,key_char_sel_y2, false);
    draw_set_color(key_bg_color);
    draw_rectangle(key_char_sel_x1+key_border_size,key_char_sel_y1+key_border_size,key_char_sel_x2-key_border_size,key_char_sel_y2-key_border_size, false);
    draw_sprite_ext(spite_chars,-1,key_char_x,key_char_y,1,1,0,key_font_color,1);

/// Draw Selected Key

if ( key_selected_show ){    

    draw_set_font(key_font);
    
    draw_set_halign(fa_center);
    draw_set_valign(fa_middle);
    
    draw_set_color(c_white);
    
    if ( abs(board_slide_count) > board_slide_buffer ){ draw_board_slide_count = board_slide_count; }
    
    // Draw block. ( Background )
    
    var temp_keybg_x1 = key_x[key_selected_id] + draw_board_slide_count - ( key_w / 2 );
    var temp_keybg_y1 = key_y[key_selected_id] - key_h - key_separation - ( key_h / 2 );
    var temp_keybg_x2 = temp_keybg_x1 + key_w;
    var temp_keybg_y2 = temp_keybg_y1 + key_h;
    
    draw_set_color(key_sel_border_color);
    draw_rectangle(temp_keybg_x1,temp_keybg_y1,temp_keybg_x2,temp_keybg_y2,false);
    draw_set_color(key_sel_bg_color);
    draw_rectangle(temp_keybg_x1+key_border_size,temp_keybg_y1+key_border_size,temp_keybg_x2-key_border_size,temp_keybg_y2-key_border_size,false);
    
    draw_set_color(key_sel_font_color);
    
    if ( key_char_1 == 1 ){  var temp_string = string_copy(key_string[key_selected_id], key_cap_type, 1); }
    else { var temp_string = key_string[key_selected_id]; }
    
    draw_text(key_x[key_selected_id]+draw_board_slide_count,key_y[key_selected_id]-key_h-key_separation,string(temp_string)); // Draw character.
}

/// [ DEBUG ] Draw Variables

if ( obj_keyfree_ctrl.keyfree_debug_mode ){

    draw_set_font(-1);
    
    draw_set_halign(fa_left);
    draw_set_valign(fa_top);
    
    draw_set_color(c_white);
    
    var text_x = 15;
    var text_y = 15;
    
    draw_text(text_x,text_y,"keyfree_acu_string:" + string(keyfree_acu_string));
    
    text_y += 25;
    
    draw_text(text_x,text_y,"key_selected_string:" + string(key_selected_string));
    
    text_y += 25;
    
    draw_text(text_x,text_y,"board_slide_auto_count:" + string(board_slide_auto_count));
}


Press Backspace
/// Close Keyboard

if ( board_backspace_close ){ scr_keyfree_close(); }

pourriez vous m'aider svp
j'aimerais que le nom marquer soit enregister en global.name pour pouvoir l'utiliser dans un highscore
Comment sauvegarder le nom marquer a partir de ce keyboard

_________________
fleche_d Pixel.Studio.Art fleche_g
Revenir en haut Aller en bas
 
Keyboard mobile et windows
Revenir en haut 
Page 1 sur 1
 Sujets similaires
-
» La téléphonie mobile objet d’une contestation grandissante
» Mobile en bois
» Demander le déverrouillage d'un téléphone mobile (lettre)
» Nrj mobile: Escroquerie ?
» Heredis pour Android

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
Forum Le CBNA :: Développement :: Entraide débutants-
Sauter vers: