I updated my FormsAndButtons script: FormsAndButtons v1.2.zip
Thanks to T.P Wang it should now work with any keyboard layout.
Overview of available elements:
//FORM ELEMENTS
//----------
//General comments:
//
//- If 'x', 'y', 'w', or 'h' depends on the size of the screen this value should be placed between brackets. For example:
//
// FormIButton("ww - 20", 0, 20, 20, skip, imgscr, func);
//
//- One can jump from element to element using the left, right, up and down arrow keys, although if 'skip' is set true the element will be skipped.
//
//- 'font' should be of type IGdiFont
//
//- 'func' should always be a function that if called without argument returns the value to be displayed and that will be called if this value is changed by the form element.
//
//- For single line text elements with a fixed width a tool tip shows the value on mouse over if clipping occurs.
//
//- Elements should be put in the array 'intobject' to work
//
//- These functions should be called in the corresponding callback functions:
// forms_on_size();
// forms_on_paint(gr);
// forms_on_mouse_move(x, y);
// forms_on_mouse_lbtn_up(x, y); //Does call wondows.Repaint()!
// forms_on_key_down(vkey);
// forms_on_char(code);
// forms_on_focus(is_focused); //Does call wondows.Repaint()!
// forms_on_timer(id);
//function FormIButton(x, y, w, h, skip, imgsrc, func)
//----------
//Draws a button using images.
//----------
//Using keyboard:
// Enter: switch button
// Left: jump to previous element
// Up: jump to previous element
// Right: jump to next element
// Down: jump to next element
//
//imgsrc:
// array of form {inactive: <<path to image>>, active: <<path to image>>, inactiveon: <<path to image>>, activeon: <<path to image>>}
//func: boolean func(boolean);
//function FormTButton(x, y, w, h, skip, text, font, func)
//----------
//Draws a button using text.
//----------
//Using keyboard:
// Enter: switch button
// Left: jump to previous element
// Up: jump to previous element
// Right: jump to next element
// Down: jump to next element
//
//func: boolean func(boolean);
//
//if w is set 0 it will be based on marginx, if h is set 0 it will be based on marginy
//function FormTButtonAlt(x, y, skip, text, font, func)
//----------
//Draws a button which is nothing more than a line of text which can be set or not set.
//----------
//Using keyboard:
// Enter: switch button
// Left: jump to previous element
// Up: jump to previous element
// Right: jump to next element
// Down: jump to next element
//
//func: boolean func(boolean);
//function FormTextBox(x, y, w, h, skip, font, func)
//----------
//Draws a text box for editing multiple lines of text.
//----------
//Using keyboard (not in edit mode):
// Enter: enter edit mode
// PgUp: scroll to start
// PgDn: scroll to end
// Left: jump to previous element
// Up: if possible scroll up, otherwise jump to previous element
// Right: jump to next element
// Down: if possible scroll down, otherwise jump to next element
//
//Using keyboard (edit mode):
// Bksp,
// Enter,
// Left,
// Up,
// Right,
// Down,
// Ins,
// Del: like expected in a text editor
// Esc: exit edit mode and send value if changed
// PgUp: cursor to start of text
// PgDn: cursor to end of text
// End: cursor to end of row
// Home: cursor to start of row
// Ctrl-Z: undo change
//
//func: string func(string);
//function FormText(x, y, w, h, skip, font, func)
//----------
//Draws multiple lines of text.
//----------
//Using keyboard:
// PgUp: scroll to start
// PgDn: scroll to end
// Left: jump to previous element
// Up: if possible scroll up, otherwise jump to previous element
// Right: jump to next element
// Down: if possible scroll down, otherwise jump to next element
//
//func: string func();
//function FormTextInput(x, y, w, skip, font, func)
//----------
//Draws single line text input.
//----------
//Using keyboard (not in edit mode):
// Enter: enter edit mode
// Left: jump to previous element
// Up: jump to previous element
// Right: jump to next element
// Down: jump to next element
//
//Using keyboard (edit mode):
// Bksp,
// Left,
// Right,
// Ins,
// Del: like expected in a text editor
// Enter: exit edit mode and send value if changed
// Esc: exit edit mode and send value if changed
// End: cursor to end of row
// Home: cursor to start of row
// Ctrl-Z: undo change
//
//func: string func(string);
//function FormTextLine(x, y, w, skip, font, func)
//----------
//Draws single line of text.
//----------
//Using keyboard:
// Left: jump to previous element
// Up: jump to previous element
// Right: jump to next element
// Down: jump to next element
//
//func: string func();
//function FormMVTextInput(x, y, w, skip, font, func)
//----------
//Draws single line text input to edit an array of values.
//----------
//Using keyboard (not in edit mode):
// Enter: enter edit mode
// Left: jump to previous element
// Up: jump to previous element
// Right: jump to next element
// Down: jump to next element
//
//Using keyboard (edit mode):
// Bksp,
// Left,
// Right,
// Ins,
// Del: like expected in a text editor
// Enter: exit edit mode and send value if changed
// Esc: exit edit mode and send value if changed
// End: cursor to end of row
// Home: cursor to start of row
// Ctrl-Z: undo change
//
//func: array func(array);
//function FormMVSTextInput(x, y, w, skip, font, func)
//----------
//Draws single line text input to edit an array of values in which the odd ones are the main values and the even ones the separators.
//----------
//Using keyboard (not in edit mode):
// Enter: enter edit mode
// Left: jump to previous element
// Up: jump to previous element
// Right: jump to next element
// Down: jump to next element
//
//Using keyboard (edit mode):
// Bksp,
// Left,
// Right,
// Ins,
// Del: like expected in a text editor
// Enter: exit edit mode and send value if changed
// Esc: exit edit mode and send value if changed
// End: cursor to end of row
// Home: cursor to start of row
// Ctrl-Z: undo change
//
//func: array func(array); where this array contains the values as odd elements and the separators as even elements
//function FormMVTextLine(x, y, w, skip, font, func)
//----------
//Draws single line showing the content of an array of values.
//----------
//Using keyboard:
// Left: jump to previous element
// Up: jump to previous element
// Right: jump to next element
// Down: jump to next element
//
//func: array func(); where this array contains the values as odd elements and the separators as even elements
//function FormKeyWords(x, y, w, skip, font, list, func)
//----------
//Draws single line showing the content of an array of key words and add new ones from a drown-down list.
//----------
//Using keyboard:
// Enter: execute selected button
// End: jump to last value
// Home: jump to first value
// Left: if possible jump to previous button, otherwise jump to previous element
// Ctrl-left:
// move selected value to the left
// Up: jump to previous element
// Right: if possible jump to next butten, otherwise jump to next element
// Ctrl-right:
// move selected value to the right
// Down: jump to next element
// Ins: insert value after selected value
// Del: remove selected value
//
//func: array func(array);
//list: array of possible values
//function FormKeyWordsH(x, y, skip, font, list, func)
//----------
//Draws single line showing a list of key words which can be set or not set.
//----------
//Using keyboard:
// Enter: add or remove selected value
// End: jump to last value
// Home: jump to first value
// Left: if possible select previous value, otherwise jump to previous element
// Up: jump to previous element
// Right: if possible select next value, otherwise jump to next element
// Down: jump to next element
//
//func: array func(array);
//list: array of possible values
//function FormKeyWordsHS(x, y, skip, font, list, func)
//----------
//Draws single line showing a list of key words of which only one can be set.
//----------
//Using keyboard:
// Enter: set or remove selected value
// End: jump to last value
// Home: jump to first value
// Left: if possible select previous value, otherwise jump to previous element
// Up: jump to previous element
// Right: if possible select next value, otherwise jump to next element
// Down: jump to next element
//
//func: string func(string);
//list: array of possible values
//function FormRating(x, y, skip, font, max, func)
//----------
//Draws line of stars to edit rating.
//----------
//Using keyboard:
// Enter: set selected rating or if this rating is set, set rating to 0
// End: jump to maximum
// Home: jump to 1
// Left: if possible select previous rating, otherwise jump to previous element
// Up: jump to previous element
// Right: if possible select next rating, otherwise jump to next element
// Down: jump to next element
//
//func: int func(int);
//max: maximum rating
//function FormDrawString(x, y, font, colour, str)
//----------
//Draws string.
Change log:
v1.2:
- Bugs fixed
- Added blinking cursor
- Solved issue with calling window.Repaint() in on_size
- Now works on all keyboard layouts
- Solved issue with enter key
- No need to include KeyboardHandling.js anymore
- Added forms_on_timer(id) to be called in on_timer(id)
- Added forms_on_char(code) to be called in on_char(code)
- Improved documentation
- Requires wsh panel mod v1.3.2
v1.1:
- Bugs fixed
- Added tag editing example