Hi there,
I'm trying to controle the X location of a button but i dont see any way to succeed.
What i want to achieve is to have that button 50 pixels from the right panel's limit.
The below code doenst work but i'm afraid that even if it did, the button will not set to a correct position if the window is resized.
// ==PREPROCESSOR==
// @name "Volume"
// @author "marc2003"
// @import "%fb2k_component_path%helpers.txt"
// @import "%fb2k_component_path%samples\js\lodash.min.js"
// @import "%fb2k_component_path%samples\js\common.js"
// @import "%fb2k_component_path%samples\js\volume.js"
// ==/PREPROCESSOR==
var buttons = new _buttons();
var w, h;
buttons.update = function () {
this.buttons.test = new _button(w-50 , 5 , 50, 40, { char: chars.stop , colour: RGB(255, 255, 0) }, null, function () { console.log('test'); }, 'TT test' );
}
buttons.update();
function on_paint(gr) {
console.log(w);
buttons.paint(gr);
}
function on_size() {
w = window.Width;
h = window.Height;
}
function on_mouse_lbtn_up(x, y) {
if (buttons.lbtn_up(x, y)) {
return;
}
}
function on_mouse_move(x, y) {
if (buttons.move(x, y)) {
return;
}
}
I've been trying to add a parameter to the paint function of _button within "common.js" with 0 success.
function _button(x, y, w, h, normal, hover, fn, tiptext) {
this.paint = function (gr, x_start) {
if (this.current) {
gr.WriteText(this.current.char, this.font, this.current.colour, x_start, this.y, this.w, this.h, 2, 2);
}
}
Any help is welcome !