Skip to content

focus

聚焦状态,暂时不支持 Group。

关键属性

focusStyle: IUIInputData

元素 focus() 时的聚焦样式, 失去焦点后自动还原。

关键方法

focus ( value?: boolean )

聚焦元素操作,单个 App 只能同时有一个元素聚焦,当一个元素聚焦时,之前元素会失焦。

归属

UI

示例

ts
import { Leafer, Rect } from 'leafer-ui'
import '@leafer-in/state'

const leafer = new Leafer({ view: window })

const rect = new Rect({
    width: 100,
    height: 100,
    fill: 'rgba(50,205,121, 0.7)',
    cornerRadius: 30,
    focusStyle: { 
        stroke: '#FEB027'
    }
})

leafer.add(rect)

setTimeout(() => {

    rect.focus()  

    setTimeout(() => { rect.focus(false) }, 2000)

}, 1000)

Released under the MIT License.