Skip to content

Commit 7621456

Browse files
committed
Merge branch 'master' of https://github.com/haxeui/haxeui-core
2 parents 677c5e6 + a6bfd14 commit 7621456

File tree

4 files changed

+105
-2
lines changed

4 files changed

+105
-2
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package haxe.ui.backend;
2+
3+
import haxe.ui.containers.dialogs.Dialog.DialogButton;
4+
import haxe.ui.containers.dialogs.Dialog.DialogEvent;
5+
import haxe.ui.containers.dialogs.Dialogs;
6+
import haxe.ui.containers.dialogs.MessageBox.MessageBoxType;
7+
8+
typedef OpenFolderDialogOptions = {
9+
@:optional var defaultPath:String;
10+
@:optional var title:String;
11+
@:optional var multiple:Null<Bool>;
12+
@:optional var hiddenFolders:Null<Bool>;
13+
@:optional var canCreateFolder:Null<Bool>;
14+
}
15+
16+
class OpenFolderDialogBase {
17+
public var selectedFolders:Array<String> = null;
18+
public var callback:DialogButton->Array<String>->Void = null;
19+
public var onDialogClosed:DialogEvent->Void = null;
20+
21+
public function new(options:OpenFolderDialogOptions = null, callback:DialogButton->Array<String>->Void = null) {
22+
this.options = options;
23+
this.callback = callback;
24+
}
25+
26+
private var _options:OpenFolderDialogOptions = null;
27+
public var options(get, set):OpenFolderDialogOptions;
28+
private function get_options():OpenFolderDialogOptions {
29+
return _options;
30+
}
31+
private function set_options(value:OpenFolderDialogOptions):OpenFolderDialogOptions {
32+
_options = value;
33+
validateOptions();
34+
return value;
35+
}
36+
37+
private function validateOptions() {
38+
if (_options == null) {
39+
options = { };
40+
}
41+
42+
if (_options.multiple == null) {
43+
_options.multiple = false;
44+
}
45+
46+
if (_options.canCreateFolder == null) {
47+
_options.canCreateFolder = false;
48+
}
49+
50+
if (_options.hiddenFolders == null) {
51+
_options.hiddenFolders = false;
52+
}
53+
}
54+
55+
public function show() {
56+
Dialogs.messageBox("OpenFolderDialog has no implementation on this backend", "Open Folder", MessageBoxType.TYPE_ERROR);
57+
}
58+
59+
private function dialogConfirmed(folders:Array<String>) {
60+
selectedFolders = folders;
61+
if (callback != null) {
62+
callback(DialogButton.OK, selectedFolders);
63+
}
64+
if (onDialogClosed != null) {
65+
var event = new DialogEvent(DialogEvent.DIALOG_CLOSED, false, selectedFolders);
66+
event.button = DialogButton.OK;
67+
onDialogClosed(event);
68+
}
69+
}
70+
71+
private function dialogCancelled() {
72+
selectedFolders = null;
73+
if (callback != null) {
74+
callback(DialogButton.CANCEL, selectedFolders);
75+
}
76+
if (onDialogClosed != null) {
77+
var event = new DialogEvent(DialogEvent.DIALOG_CLOSED, false, selectedFolders);
78+
event.button = DialogButton.CANCEL;
79+
onDialogClosed(event);
80+
}
81+
}
82+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package haxe.ui.backend;
2+
3+
class OpenFolderDialogImpl extends OpenFolderDialogBase {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package haxe.ui.containers.dialogs;
2+
3+
import haxe.ui.backend.OpenFolderDialogImpl;
4+
5+
#if haxeui_expose_all
6+
@:expose
7+
#end
8+
class OpenFolderDialog extends OpenFolderDialogImpl {
9+
}

haxe/ui/util/StringUtil.hx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,22 @@ class StringUtil {
122122
var p = s.indexOf(".");
123123
if (p == -1 && precision > 0) {
124124
p = s.length;
125-
s += ".";
125+
s += haxe.ui.locale.Formats.decimalSeparator;
126126
}
127127
s = StringTools.rpad(s, "0", p + precision + 1);
128128
}
129129
s += suffix;
130130
} else {
131-
s = humanReadableRegex.replace(s, haxe.ui.locale.Formats.thousandsSeparator);
131+
var decimalSeparatorIndex = s.indexOf(".");
132+
if (decimalSeparatorIndex == -1) {
133+
s = humanReadableRegex.replace(s, haxe.ui.locale.Formats.thousandsSeparator);
134+
} else {
135+
var integerPart = s.substring(0, s.indexOf("."));
136+
var decimalPart = s.substring(s.indexOf(".") + 1);
137+
s = humanReadableRegex.replace(integerPart, haxe.ui.locale.Formats.thousandsSeparator);
138+
s += haxe.ui.locale.Formats.decimalSeparator;
139+
s += decimalPart;
140+
}
132141
}
133142

134143
return s;

0 commit comments

Comments
 (0)