MCPcopy Create free account
hub / github.com/SpartanJ/eepp / onCreateContextMenu

Method onCreateContextMenu

src/eepp/ui/uitextinput.cpp:1015–1052  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1013}
1014
1015bool UITextInput::onCreateContextMenu( const Vector2i& position, const Uint32& flags ) {
1016 if ( mCurrentMenu )
1017 return false;
1018
1019 UIPopUpMenu* menu = UIPopUpMenu::New();
1020
1021 createDefaultContextMenuOptions( menu );
1022
1023 ContextMenuEvent event( this, menu, Event::OnCreateContextMenu, position, flags );
1024 sendEvent( &event );
1025
1026 if ( menu->getCount() == 0 ) {
1027 menu->close();
1028 return false;
1029 }
1030
1031 menu->setCloseOnHide( true );
1032 menu->on( Event::OnItemClicked, [this]( const Event* event ) {
1033 if ( !event->getNode()->isType( UI_TYPE_MENUITEM ) )
1034 return;
1035 UIMenuItem* item = event->getNode()->asType<UIMenuItem>();
1036 std::string txt( item->getId() );
1037 mDoc.execute( txt );
1038 } );
1039
1040 Vector2f pos( position.asFloat() );
1041 Int32 init = selCurInit();
1042 Int32 end = selCurEnd();
1043 menu->nodeToWorldTranslation( pos );
1044 UIMenu::findBestMenuPos( pos, menu );
1045 menu->setPixelsPosition( pos );
1046 menu->show();
1047 menu->on( Event::OnClose, [this]( const Event* ) { mCurrentMenu = nullptr; } );
1048 mCurrentMenu = menu;
1049 selCurInit( init );
1050 selCurEnd( end );
1051 return true;
1052}
1053
1054void UITextInput::setHintDisplay( HintDisplay display ) {
1055 mHintDisplay = display;

Callers

nothing calls this directly

Calls 15

selCurInitFunction · 0.85
selCurEndFunction · 0.85
setCloseOnHideMethod · 0.80
getNodeMethod · 0.80
setPixelsPositionMethod · 0.80
closeMethod · 0.65
getIdMethod · 0.65
NewFunction · 0.50
getCountMethod · 0.45
onMethod · 0.45
isTypeMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected