Interface: FloatingWindow


CloudControl Pro 9 Docs / floating_window / FloatingWindow

Interface: FloatingWindow

floating_window.FloatingWindow

Floating window object. Used to control the position, size, and content of the floating window.

Hierarchy

  • unknown

    FloatingWindow

Table of contents

Properties

Methods

Properties

isShowing

Readonly isShowing: boolean

Whether the floating window is showing.


position

Readonly position: Point

The current position of the floating window.


size

Readonly size: Size


view

Optional Readonly view: any

The content view of the floating window, or undefined if not set.

Methods

addFlags

addFlags(flags): void

Add specific flags to floating windows, such as FLAG_NOT_TOUCHABLE to make the window untouchable, FLAG_NOT_FOCUSABLE to make the window unfocusable.

This module comes with some commonly used flags, but the complete flags need to visit the Android documentation WindowManager.LayoutParamsopen in new window.

Example

"nodejs";
const { createWindow, FLAG_NOT_TOUCHABLE } = require("floating_window");
async function main() {
  const window = createWindow();
  window.setViewFromXml(...);
  window.addFlags(FLAG_NOT_TOUCHABLE)
  window.show();
}
main();

Parameters

Name Type
flags number

Returns

void


close

close(): Promise<void>

Close the floating window.

Returns

Promise<void>


enableDrag

enableDrag(view, options?): DragGesture

Enable drag gesture of the floating window.

Parameters

Name Type Description
view View the drag anchor view of the drag gesture, drag the View to drag the whole floating window
options? DragGestureOptions drag options of the floating window

Returns

DragGesture

DragGesture object, which can be used to disable the gesture


on

on(event, listener): FloatingWindow

Parameters

Name Type
event "touch"
listener (event: any) => void

Returns

FloatingWindow


removeFlags

removeFlags(flags): void

Remove certain flags for floating windows, such as FLAG_NOT_TOUCHABLE to make the window touchable, FLAG_NOT_FOCUSABLE to make the window focusable.

This module comes with some commonly used flags, but the complete flags need to visit the Android documentation WindowManager.LayoutParamsopen in new window.

Example

"nodejs";
const { createWindow, FLAG_LAYOUT_NO_LIMITS, FLAG_NOT_FOCUSABLE } = require("floating_window");
async function main() {
  const window = createWindow();
  window.setViewFromXml(...);
  window.removeFlags(FLAG_LAYOUT_NO_LIMITS | FLAG_NOT_FOCUSABLE)
  window.show();
}
main();

Parameters

Name Type
flags number

Returns

void


setPosition

setPosition(x, y): Promise<void>

Set the position of the floating window.

Parameters

Name Type Description
x number x coordinate
y number y coordinate

Returns

Promise<void>


setSize

setSize(width, height): Promise<void>

Set the size of the floating window, unit is pixel.

Parameters

Name Type Description
width number width, can be negative, see Size
height number height, can be negative, see Size

Returns

Promise<void>


setView

setView(view): void

Set the given View as the content of the floating window.

Parameters

Name Type
view View

Returns

void


setViewFromXml

setViewFromXml(xml): void

Parse xml to View, set as the content of the floating window.

Parameters

Name Type
xml string

Returns

void


setViewFromXmlFile

setViewFromXmlFile(xmlFile): Promise<void>

Parse the given path of xml file to View, set as the content of the floating window. The reading of the file is asynchronous, so this function is also asynchronous.

Parameters

Name Type Description
xmlFile string xml file path

Returns

Promise<void>


show

show(): Promise<void>

Show the floating window.

Note that showing the floating window needs to start the floating window service, which may not be possible if the application is in the background. Also, showing the floating window needs floating window permission, if it does not have permission, the floating window may not be displayed. You can use manageDrawOverlays and canDrawOverlays to query and jump to floating window permission.

Returns

Promise<void>