Languages

Menu
Sites
Language
How to select text from web control page

Hi,

Any one please explain me How to select text from web control page.

give me some sample code.

To select text and highlight with color and  copy into another string.( As we do on web page)

Thanks

Rajyalakshmi
 

Edited by: Brock Boland on 17 Mar, 2014 Reason: Paragraph tags added automatically from tizen_format_fix module.

Responses

8 Replies
Nikhil M
Hi, The following helped to obtain a selected text: 1. Include interface ->Tizen::Ui::ITouchEventListener and add the event listener to the the web control [__pWeb->AddTouchEventListener(*this);] 2. Using "SetBlockSelectionPosition" and "GetTextFromBlock" api's provided in the Tizen::Web::Controls::Web class, the required text can be obtained. 3. Set starting point in "OnTouchMoved" callback of "ITouchEventListener ", and read the text in "OnTouchReleased". Following code shows the obtained text in log: void TestAppMainForm::OnTouchMoved (const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo) { if(!__firstPosFlag) //Use a flag to set position for the first point selected { __pWeb->SetBlockSelectionPosition(currentPosition); __firstPosFlag = true; } } void TestAppMainForm::OnTouchReleased (const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo) { Point start, end; String str = __pWeb->GetTextFromBlock(); __pWeb->GetBlockRange(start, end); AppLog("Text Selected %ls", str.GetPointer()); AppLog("Text Block Range - %d,%d to %d,%d", start.x, start.y, end.x, end.y); __firstPosFlag = false; }
y Rajyalakshmi
Hi, It is working fine. but when i started selection only one word is selecting. Why i dnt know please explain me. I want to select block of text. Thanks Rajyalakshmi
Nikhil M
Hi, Initially a single word is selected as "SetBlockSelectionPosition" api binds the nearest word. Using the end markers that appear after a word is selected, you can select the block of text.
y Rajyalakshmi
Hi Nikhil, can you please explain me clearly. how to select. Thanks Rajyalakshmi
y Rajyalakshmi
Hi Nikhil, Thanks I got selection procedure. When we select that text can we make that block of text as underline while selecting...? Thanks Rajyalakshmi
Nikhil M
Hi Rajyalakshmi, I don't think you can underline the selected text as it is a part of the website, unlike a document etc..
y Rajyalakshmi
Hi Nikhil, Can we write some actions on selected text. as changing color of selected block or adding to note like wise. After selecting the block of code how to write an action. like when we click on that block of selected code to display a context menu with some optins? Thanks Rajyalakshmi
Nikhil M
Hi Rajyalakshmi, You cannot make such changes to the text in the webpage itself, you've to copy it and use that elsewhere. To display a context menu that can show options like 'copy', use Tizen::Ui::Clipboard class.