Skip to content

Commit b2bfcf8

Browse files
author
AleBles
committed
Big update
1 parent 501adb1 commit b2bfcf8

14 files changed

+336
-25
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015 Gembly
3+
Copyright (c) 2015 Orange Games
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ var password = game.add.inputField(10, 90, {
4747

4848
Current Limitations
4949
-------------------
50-
- ctrl+a works, but isn't visible
51-
- Clicking in the box doesn't update the cursor position
5250
- Updates are slow when typing fast (type slower you!!)
5351

5452
Properties
@@ -71,6 +69,7 @@ Properties
7169
- **font**: string (14px Arial by default) The font that is used for the input box, covers the input text, placeholder and cursor
7270
- **min**: string (none by default) The minimum number for the input field, only for number input fields
7371
- **max**: string (none by default) The maximum number for the number input field, or the maxLength for other input fields
72+
- **selectionColor**: string (rgba(179, 212, 253, 0.8) by default) The default color for the text selection highlight.
7473

7574
Browser Support
7675
---------------
@@ -85,14 +84,15 @@ Tested on:
8584

8685
Changelog
8786
---------
88-
### 0.2.0
87+
### 1.0.0
8988
* Updated example
9089
* Added masking for texts so they don't overflow the box anymore
9190
* Combined max/maxLength
9291
* Moved dom manipulation to seperate class
9392
* Added option for aligning texts
9493
* Keyboard can now be used to update caret position
9594
* Clicking in the input field now changes the caret position
95+
* ctrl+a can be used to select text
9696

9797
### 0.1.4
9898
* You can now reset text

build/phaser-input.d.ts

+32
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ declare module Fabrique {
1616
setMax(max: string, min?: string): void;
1717
value: string;
1818
focus(): void;
19+
hasSelection: boolean;
20+
caretStart: number;
21+
caretEnd: number;
1922
getCaretPosition(): number;
23+
setCaretPosition(pos: number): void;
2024
}
2125
}
2226
declare module Fabrique {
@@ -37,6 +41,7 @@ declare module Fabrique {
3741
min?: string;
3842
max?: string;
3943
textAlign?: string;
44+
selectionColor?: string;
4045
}
4146
class InputField extends Phaser.Sprite {
4247
private placeHolder;
@@ -49,6 +54,7 @@ declare module Fabrique {
4954
value: string;
5055
private inputOptions;
5156
private domElement;
57+
private selection;
5258
constructor(game: Phaser.Game, x: number, y: number, inputOptions?: InputOptions);
5359
/**
5460
* This is a generic input down handler for the game.
@@ -72,6 +78,9 @@ declare module Fabrique {
7278
* Focus is lost on the input element, we disable the cursor and remove the hidden input element
7379
*/
7480
private endFocus();
81+
/**
82+
*
83+
*/
7584
private startFocus();
7685
/**
7786
* Update the text value in the box, and make sure the cursor is positioned correctly
@@ -87,6 +96,16 @@ declare module Fabrique {
8796
* @returns {number}
8897
*/
8998
private getCaretPosition();
99+
/**
100+
* Set the caret when a click was made in the input field
101+
*
102+
* @param e
103+
*/
104+
private setCaretOnclick(e);
105+
/**
106+
* This checks if a select has been made, and if so highlight it with blue
107+
*/
108+
private updateSelection();
90109
/**
91110
* Event fired when a key is pressed, it takes the value from the hidden input field and adds it as its own
92111
*/
@@ -106,6 +125,19 @@ declare module Fabrique {
106125
constructor(game: Phaser.Game, inputOptions: InputOptions);
107126
}
108127
}
128+
declare module Fabrique {
129+
class SelectionHighlight extends Phaser.Graphics {
130+
private inputOptions;
131+
constructor(game: Phaser.Game, inputOptions: InputOptions);
132+
updateSelection(rect: PIXI.Rectangle): void;
133+
static rgb2hex(color: {
134+
r: number;
135+
g: number;
136+
b: number;
137+
a: number;
138+
}): number;
139+
}
140+
}
109141
declare module Fabrique {
110142
class TextMask extends Phaser.Graphics {
111143
constructor(game: Phaser.Game, inputOptions: InputOptions);

build/phaser-input.js

+127-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/phaser-input.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)