+ __pImageMenu->SetFocusable(true);
+
+ CATCH: return r;
+
+}
+
+result
+MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPasteOption = false)
+{
+ result r = E_SUCCESS;
+ bool clipboardAvailable = true;
+ ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
+
+ AppLog("MainForm::InitSelectTextContextMenu clicked on text");
+ if (__pImageMenu != null)
+ {
+ delete __pImageMenu;
+ __pImageMenu = null;
+ }
+// FloatPoint q(0.0,0.0);
+// __pWebViewer->GetBlockRange(p,q);
+ if(p.y < 0)
+ p.y =0;
+ if(p.y < 150)
+ {
+ p.y = p.y + 100;
+ if(GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE )
+ {
+ p.y = p.y - 50;
+ }
+ direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
+ }
+ else if(__pWebViewer != null && (p.y > (__pWebViewer->GetHeight() + __pWebViewer->GetY())))
+ {
+ p.y = __pWebViewer->GetHeight() + __pWebViewer->GetY();
+ }
+ else
+ {
+ if(GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE )
+ {
+ AppLog("asdasdafdsfdgfd");
+ p.y = p.y - 50;
+ }
+ direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
+ }
+
+
+ Clipboard* pClipboard = Clipboard::GetInstance();
+
+ if(pClipboard == null)
+ {
+ clipboardAvailable = false;
+ }
+ else
+ {
+ // Retrieves a latest item
+ ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
+
+ if(pItem == null)
+ {
+ clipboardAvailable = false;
+ }
+ else
+ {
+ //Gets data from the clipboard item
+ String* pString = dynamic_cast<String*>(pItem->GetData());
+
+ if(pString == null)
+ {
+ clipboardAvailable = false;
+ }
+ }
+ }
+ if(clipboardAvailable == false && (onlyPasteOption == true || __pHitElementResult->GetAttributeValue("type").Equals(L"password",false) == true))
+ {
+ return E_FAILURE;
+ }
+ __pImageMenu = new (std::nothrow) ContextMenu();
+ r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
+ TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
+
+ if(onlyPasteOption == false && __pHitElementResult->GetAttributeValue("type").Equals(L"password",false) == false)
+ {
+ r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
+ }
+ if ((pasteOption || onlyPasteOption) && clipboardAvailable == true)
+ {
+ r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
+ }
+ if(onlyPasteOption == false && __pHitElementResult->GetAttributeValue("type").Equals(L"password",false) == false)
+ {
+ r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
+ r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
+ }
+
+ __pImageMenu->SetMaxVisibleItemsCount(3);
+ __pImageMenu->AddActionEventListener(*this);
+ SetControlAlwaysOnTop(*__pImageMenu, true);
+ __pImageMenu->SetFocusable(true);