aboutsummaryrefslogtreecommitdiff
path: root/src/debug/Test.tsx
blob: 7bc70615f1c955d5d76c3d97cc03c9ab0aca8af6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import * as React from 'react';
import * as ReactDOM from 'react-dom';

class TestInternal extends React.Component {
    onContextMenu = (e: React.MouseEvent) => {
        console.log("Internal");
        e.stopPropagation();
    }

    onPointerDown = (e: React.MouseEvent) => {
        console.log("pointer down")
        e.preventDefault();
    }

    render() {
        return <div onContextMenu={this.onContextMenu} onPointerDown={this.onPointerDown}
            onPointerUp={this.onPointerDown}>Hello world</div>
    }
}

class TestChild extends React.Component {
    onContextMenu = () => {
        console.log("Child");
    }

    render() {
        return <div onContextMenu={this.onContextMenu}><TestInternal /></div>
    }
}

class TestParent extends React.Component {
    onContextMenu = () => {
        console.log("Parent");
    }

    render() {
        return <div onContextMenu={this.onContextMenu}><TestChild /></div>
    }
}

ReactDOM.render((
    <div style={{ position: "absolute", width: "100%", height: "100%" }}>
        <TestParent />
    </div>),
    document.getElementById('root')
);