Skip to content

Commit ae8ac40

Browse files
author
pandamicro
committed
Exit fullscreen for edit box
1 parent f0511de commit ae8ac40

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

extensions/editbox/CCEditBox.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ cc.EditBox = cc.ControlButton.extend({
263263
tmpEdTxt.style.active = 0;
264264
tmpEdTxt.style.outline = "medium";
265265
tmpEdTxt.style.padding = "0";
266+
267+
this.__fullscreen = false;
266268
var onCanvasClick = function() { this._edTxt.blur();};
267269
this._onCanvasClick = onCanvasClick.bind(this);
268270

@@ -282,6 +284,15 @@ cc.EditBox = cc.ControlButton.extend({
282284
};
283285
this._keyPressEvent = keypressEvent.bind(this);
284286
var focusEvent = function () {
287+
// Exit fullscreen
288+
if(cc.view.isAutoFullScreenEnabled()) {
289+
this.__fullscreen = true;
290+
cc.view.enableAutoFullScreen(false);
291+
cc.screen.exitFullScreen();
292+
} else {
293+
this.__fullscreen = false;
294+
}
295+
285296
if (this._edTxt.value === this._placeholderText) {
286297
this._edTxt.value = "";
287298
this._edTxt.style.fontSize = this._edFontSize + "px";
@@ -297,6 +308,11 @@ cc.EditBox = cc.ControlButton.extend({
297308
};
298309
this._focusEvent = focusEvent.bind(this);
299310
var blurEvent = function () {
311+
// Resume fullscreen logic
312+
if(this.__fullscreen) {
313+
cc.view.enableAutoFullScreen(true);
314+
}
315+
300316
if (this._edTxt.value === "") {
301317
this._edTxt.value = this._placeholderText;
302318
this._edTxt.style.fontSize = this._placeholderFontSize + "px";

0 commit comments

Comments
 (0)