kaplay-ui 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/inputs/index.js +41 -1
- package/package.json +1 -1
package/inputs/index.js
CHANGED
|
@@ -133,7 +133,7 @@ export const makeCheckbox = (x = 0, y = 0, width = 25, height = 25) => {
|
|
|
133
133
|
};
|
|
134
134
|
|
|
135
135
|
/**
|
|
136
|
-
* Makes
|
|
136
|
+
* Makes switch
|
|
137
137
|
* @param {number} x - Switch x postion (default is 0)
|
|
138
138
|
* @param {number} y - Switch y postion (default is 0)
|
|
139
139
|
* @param {number} width - Switch width (default is 50)
|
|
@@ -184,3 +184,43 @@ export const makeSwitch = (x = 0, y = 0, width = 50, height = 25) => {
|
|
|
184
184
|
|
|
185
185
|
return switchBase;
|
|
186
186
|
};
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Makes text input
|
|
190
|
+
* @param {number} x - Text input x postion (default is 0)
|
|
191
|
+
* @param {number} y - Text input y postion (default is 0)
|
|
192
|
+
* @param {number} width - Text input width (default is 400)
|
|
193
|
+
* @param {number} txtSize - Text input text size (default is 15)
|
|
194
|
+
* @param {number} pad - Text input padding (default is 10)
|
|
195
|
+
* @param {boolean} hasFocus - Text input focus (default is true)
|
|
196
|
+
* @returns {GameObj}
|
|
197
|
+
*/
|
|
198
|
+
export const makeTextInput = (
|
|
199
|
+
x = 0,
|
|
200
|
+
y = 0,
|
|
201
|
+
width = 400,
|
|
202
|
+
txtSize = 15,
|
|
203
|
+
pad = 10,
|
|
204
|
+
hasFocus = true
|
|
205
|
+
) => {
|
|
206
|
+
// Text input container
|
|
207
|
+
const inputBase = make([
|
|
208
|
+
rect(width, txtSize + pad * 2),
|
|
209
|
+
pos(x, y),
|
|
210
|
+
area(),
|
|
211
|
+
outline(1),
|
|
212
|
+
]);
|
|
213
|
+
|
|
214
|
+
// Text input
|
|
215
|
+
const input = make([
|
|
216
|
+
text("", { width: width - pad * 2, size: txtSize }),
|
|
217
|
+
textInput(hasFocus),
|
|
218
|
+
color(BLACK),
|
|
219
|
+
pos(pad, pad),
|
|
220
|
+
area(),
|
|
221
|
+
]);
|
|
222
|
+
|
|
223
|
+
inputBase.add(input);
|
|
224
|
+
|
|
225
|
+
return inputBase;
|
|
226
|
+
};
|