Skip to content

Commit 1f6a58e

Browse files
committed
NOTE; add unique id to default control names, fix #16, see issue for discussion
1 parent 28dbfa8 commit 1f6a58e

File tree

15 files changed

+32
-14
lines changed

15 files changed

+32
-14
lines changed

mint/Button.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Button extends Control {
3232

3333
options = _options;
3434

35-
def(options.name, 'button');
35+
def(options.name, 'button.${Helper.uniqueid()}');
3636
def(options.mouse_input, true);
3737

3838
super(options);

mint/Checkbox.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Checkbox extends Control {
4343

4444
options = _options;
4545

46-
def(options.name, 'checkbox');
46+
def(options.name, 'checkbox.${Helper.uniqueid()}');
4747
def(options.mouse_input, true);
4848

4949
super(_options);

mint/Control.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ class Control {
228228

229229
children = [];
230230

231-
name = def(_options_.name, 'control');
231+
name = def(_options_.name, 'control.${Helper.uniqueid()}');
232232
user = _options_.user;
233233
depth_offset = def(_options_.depth, 0);
234234

mint/Dropdown.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Dropdown extends Control {
3535

3636
options = _options;
3737

38-
def(options.name, 'dropdown');
38+
def(options.name, 'dropdown.${Helper.uniqueid()}');
3939
def(options.mouse_input, true);
4040

4141
//create the base control

mint/Image.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Image extends Control {
4040

4141
options = _options;
4242

43-
def(options.name, 'image');
43+
def(options.name, 'image.${Helper.uniqueid()}');
4444

4545
super(_options);
4646

mint/Label.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Label extends Control {
4848

4949
options = _options;
5050

51-
def(options.name, 'label');
51+
def(options.name, 'label.${Helper.uniqueid()}');
5252

5353
super(options);
5454

mint/List.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class List extends Control {
2626
items = [];
2727
options = _options;
2828

29-
def(options.name, 'list');
29+
def(options.name, 'list.${Helper.uniqueid()}');
3030
def(options.mouse_input, true);
3131

3232
super(options);

mint/Panel.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Panel extends Control {
2828

2929
options = _options;
3030

31-
def(options.name, 'panel');
31+
def(options.name, 'panel.${Helper.uniqueid()}');
3232

3333
super(options);
3434

mint/Progress.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Progress extends Control {
3535

3636
options = _options;
3737

38-
def(options.name, 'progress');
38+
def(options.name, 'progress.${Helper.uniqueid()}');
3939

4040
super(options);
4141

mint/Scroll.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class Scroll extends Control {
5555

5656
options = _options;
5757

58-
def(options.name, 'scroll');
58+
def(options.name, 'scroll.${Helper.uniqueid()}');
5959
def(options.mouse_input, true);
6060

6161
units_to_scroll_h = def(options.units_to_scroll_h, 16);

mint/Slider.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Slider extends Control {
6060

6161
options = _options;
6262

63-
def(options.name, 'slider');
63+
def(options.name, 'slider.${Helper.uniqueid()}');
6464
def(options.mouse_input, true);
6565

6666
max = def(options.max, 1);

mint/TextEdit.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class TextEdit extends Control {
6868

6969
options = _options;
7070

71-
def(options.name, 'textedit');
71+
def(options.name, 'textedit.${Helper.uniqueid()}');
7272
def(options.mouse_input, true);
7373
def(options.key_input, true);
7474

mint/Window.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Window extends Control {
6161
onclose = new Signal();
6262
oncollapse = new Signal();
6363

64-
def(options.name, 'window');
64+
def(options.name, 'window.${Helper.uniqueid()}');
6565
def(options.mouse_input, true);
6666

6767
super(options);

mint/types/Types.hx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,23 @@ class Helper {
216216

217217
} //in_rect
218218

219+
static public function uniqueid(?val:Null<Int>) : String {
220+
221+
if(val == null) val = Std.random(0x7fffffff);
222+
223+
function to_char(value:Int) : String {
224+
if (value > 9) {
225+
var ascii = (65 + (value - 10));
226+
if (ascii > 90) { ascii += 6; }
227+
return String.fromCharCode(ascii);
228+
} else return Std.string(value).charAt(0);
229+
} //to_char
230+
231+
var r = Std.int(val % 62);
232+
var q = Std.int(val / 62);
233+
if (q > 0) return uniqueid(q) + to_char(r);
234+
else return Std.string(to_char(r));
235+
236+
} //uniqueid
237+
219238
} //Helper

tests/test_luxe/src/tests/KitchenSink.hx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,6 @@ class KitchenSink extends State {
340340

341341
new mint.Button({
342342
parent: canvas,
343-
name: 'button2',
344343
x: 76, y: 52, w: 32, h: 32,
345344
text: 'O',
346345
options: { color_hover: new Color().rgb(0xf6007b) },

0 commit comments

Comments
 (0)