2017-05-02 3 views

답변

1

OK-이 API는 내가 완전히 문서화되지 않은 볼 수 있지만 마우스 주위의 상황에 맞는 메뉴를 생성합니다 다음을 클릭만큼 멀리

class Preview extends React.Component { 
    constructor (props) { 
    super(props) 
    this.showContextMenu = this.showContextMenu.bind(this) 
    this.state = { showContextMenu: false } 
    } 
    showContextMenu (e, text) { 
    this.setState({ 
     showContextMenu: ((text.length > 0) ? true : false), 
     selectionText: text, 
     targetPoint: { 
     x: e.clientX, 
     y: e.clientY 
     } 
    }) 
    } 
    render() { 
    return (
     <div className='ms-font-m ms-bgColor-themeLighter' onMouseUp={(e) => this.showContextMenu(e, window.getSelection().toString())}> 
     <div> 
      { this.state.showContextMenu && <ContextualMenu useTargetPoint="true" targetPoint={this.state.targetPoint} items={[ { key: '1', name: "boo" }, { key: '2', name: "yah" }]} /> } 
     </div> 
     <p> 
      This is a really interesting paragraph, etc... 
     </p> 
     </div> 
    ) 
    } 
}