Select Git revision
serial_list.py
button.js 1.19 KiB
/*
contact
*/
import { Hunkify, Input, Output, State } from '../hunks.js'
function Button() {
Hunkify(this, 'Button')
let onclk = new Output('boolean', 'onclick', this)
this.outputs.push(onclk)
/* aspirationally
this.outputs.mousedown
this.outputs.mouseup
*/
/*
let strang = new State('string', 'strng', 'start value')
let numbr = new State('number', 'nmbr', 101)
let blen = new State('boolean', 'bln', false)
this.states.push(strang, numbr, blen)
*/
this.dom = {}
this.init = () => {
// manager calls this once
this.log('HELLO BUTTON')
this.dom = $('<div>').get(0)
}
this.onload = (dom) => {
// function equivalent, our .dom element is loaded into ~ the d o m ~
let contact = $('<div>').addClass('btn').append('! contact !').get(0)
$(this.dom).append(contact)
contact.addEventListener('click', (evt) => {
//console.log('button hunk down')
if(onclk.io()){
console.warn("button attempts to push to occupied output")
} else {
onclk.put(true)
}
})
}
this.loop = () => {
// ...
}
}
export default Button