I want to add custom floating spinner - xamarin.android

I want to add custom floating spinner. How to add like this ??
I have tried with AutoComplete textview inside TextInputLayout but it's not properly worked.
http://prntscr.com/mm8ksc
//SocietySpinnerLayout.axml
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:id="#+id/societySpinnerLayout"
app:errorTextAppearance="#style/ErrorText"
android:theme="#style/CommonTextStyleTheme">
<AutoCompleteTextView
android:id="#+id/societySpinner"
android:paddingBottom="#dimen/padding_20"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#4C5375"
android:textSize="#dimen/textSize_14"
android:hint="SOCIETY"
android:paddingEnd="60dp"
android:textCursorDrawable="#null"
android:inputType="textPhonetic" />
</android.support.design.widget.TextInputLayout>
//SocietySpinner.cs
private void BindToMySociety()
{
//String[] arraySociety = Resources.GetStringArray(Resource.Array.arraySociety);
ArrayAdapter adapter = new SpinnerSocietyAdapter(this, Resource.Layout.PublisherSpinnerItemLayout, HelperNavigation.LstSociety);
_societySpinner.Adapter = adapter;
if (_societySpinner.HasFocus)
{
InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
imm.HideSoftInputFromWindow(Window.CurrentFocus.WindowToken, 0);
}
_societySpinner.SetOnTouchListener(this);
_societySpinner.Focusable = false;
// _societySpinner.Click+=_societySpinner_Click;
_societySpinner.ItemClick += _societySpinner_ItemClick;
_societySpinner.SetOnDismissListener(this);
if(_selectedSociety!=null)
{
_societySpinner.Text = _selectedSociety.name;
}
}
private void _societySpinner_Click(object sender, EventArgs e)
{
try
{
// _societySpinner.Text = string.Empty;
if (!string.IsNullOrEmpty(_societySpinner.Text))
{
_societySpinner.Text = string.Empty;
_societySpinnerLayout.Typeface = ItalicFont;
_societySpinner.Typeface = ItalicFont;
}
((AutoCompleteTextView)_societySpinner).ShowDropDown();
}
catch (Exception ex)
{
}
}
public bool OnTouch(View v, MotionEvent e)
{
try
{
// _societySpinner.Text = string.Empty;
if (!string.IsNullOrEmpty(_societySpinner.Text))
{
_societySpinner.Text = string.Empty;
_societySpinnerLayout.Typeface = ItalicFont;
_societySpinner.Typeface = ItalicFont;
}
((AutoCompleteTextView)v).ShowDropDown();
return false;
}
catch (Exception ex)
{
return false;
}
}
public void OnDismiss()
{
if(_selectedSociety!=null)
{
if (!string.IsNullOrEmpty(_selectedSociety.name))
{
_societySpinner.Text = _selectedSociety.name;
_societySpinnerLayout.Typeface = RegularFont;
_societySpinner.Typeface = RegularFont;
}
}
else
{
_societySpinnerLayout.Typeface = ItalicFont;
_societySpinner.Typeface = ItalicFont;
}
}
I have tried with above code.But sometime it's throwing out of bound exception.and it's not properly worked.Please give me solution to how to create floating spinner.

I was thinking about this for a long while as I did a similar implementation in one of my earlier projects and then I remembered that I was using the Ganfra Material Spinner to achieve this:
There is a sample project available here
You can use it in XML like below:
<fr.ganfra.materialspinner.MaterialSpinner
android:id="#+id/spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:ms_multiline="false"
app:ms_hint="hint"
app:ms_enableFloatingLabel="false"
app:ms_enableErrorLabel="false"
app:ms_floatingLabelText="floating label"
app:ms_baseColor="#color/base"
app:ms_highlightColor="#color/highlight"
app:ms_errorColor="#color/error"
app:ms_typeface="typeface.ttf"
app:ms_thickness="2dp"
app:ms_hintColor="#color/hint"
app:ms_arrowColor="#color/arrow"
app:ms_arrowSize="16dp"
app:ms_alignLabels="false"
app:ms_floatingLabelColor="#color/floating_label"/>
You can set a hint and a floating label text. If no floating label text is provided, the hint will be set instead.
You use it like a regular spinner, setting an adapter to it:
string[] ITEMS = {"Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6"};
var adapter = new ArrayAdapter<String>(this, Android.Resource.Layout.SimpleSpinnerItem, ITEMS);
adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
var spinner = FindViewById<MaterialSpinner>(Resource.Id.spinner1);
spinner.Adapter = adapter;
If you need to set an error message, you can do it the same way as an EditText:
// Activate
spinner.Error = "Error";
// Deactivate
spinner.Error = null;
You can choose to have a scrolling animation or to set the error message on multiple lines with the ms_multiline attribute in XML (default is true).

Related

Xamarin iOS - Text Changed event not showing results

Xamarin iOS is testing me lately. I have a form which has as Entry value for searching. This entry control has a text changed event. All works great , event executes and values passed as expected however the results dont appear on screen.
If i rotate the device, in this case and ipad, the results show. Everything in Android works as expected. Frustrating
CancellationTokenSource _cts;
private void Search_TextChanged(object sender, TextChangedEventArgs e)
{
try
{
_cts?.Cancel(); // cancel previous search
}
catch { } // in case previous search completed
ShowResults((Entry)sender);
}
private async void ShowResults(Entry entry)
{
using (_cts = new CancellationTokenSource())
{
try
{
await Task.Delay(TimeSpan.FromSeconds(1), _cts.Token); // buffer
using (UserDialogs.Instance.Loading("Loading. . ."))
{
ObservableCollection<TMDB_Movie> itemSourceCollection = new ObservableCollection<TMDB_Movie>();
MovieSearchVM context = (MovieSearchVM)BindingContext;
try
{
if (!IsPublicCollection)
{
var results = PrivateCollection.Where(x => x.Title.Contains(entry.Text));
foreach (TMDB_Movie movie in results)
{
movie.PublicCollection = true;
movie.Type = "Digital";
itemSourceCollection.Add(movie);
}
}
else
{
if (PhysicalDevice.HasInternetConnection())
{
TMDB_Request request = new TMDB_Request();
TMDB_Movies movies = await request.ByMovieName(entry.Text, CustomSettings.GetSettings().Language);
int i = 0;
foreach (var movie in movies.Results)
{
if (i < 10)
{
FanartTv tv = new FanartTv();
movie.Movieposter = await tv.GetSingleMoviePoster(movie.Id);
if (movie.Release_date != null)
{
char[] Separator = new char[] { '-' };
string[] year = movie.Release_date.Split(Separator, StringSplitOptions.None);
movie.Release_year = year[0];
}
movie.PublicCollection = true;
itemSourceCollection.Add(movie);
i++;
}
else
{
break;
}
}
}
}
context.MovieCollection = itemSourceCollection;
}
catch { }
}
}
catch { }
}
}
View Model
private ObservableCollection<TMDB_Movie> _MovieCollection = new ObservableCollection<TMDB_Movie>();
public ObservableCollection<TMDB_Movie> MovieCollection
{
get { return _MovieCollection; }
set
{
_MovieCollection = value;
RaisePropertyChanged("MovieCollection");
}
}
XAML
<Grid Style="{StaticResource StyleBaseGrid}" Grid.Row="2" HorizontalOptions="FillAndExpand" >
<SfListView:SfListView x:Name="GridMovieCollection"
ItemsSource="{Binding MovieCollection}"
ItemTemplate="{StaticResource StandardPosterTemplate}"
Margin="-5,0,0,0"
ItemSize="125"
ItemSpacing="0,0,0,0"
AutoFitMode="None"
SelectionBackgroundColor="Transparent"
ItemHolding="GridMovieCollection_ItemHolding"
ItemTapped="GridMovieCollection_ItemTapped" >
</SfListView:SfListView>
</Grid>
I have no clue why rotation solves this but i guess it updates the controls width and height properties and refreshes the screen.
Any ideas how i can force refresh the screen or if there is anything wrong with my code?
Android look

progress indicator in xamarin.ios app

I am a a beginner at Xamarin and have a problem. I must change from spinner progress bar to usual progress bar, like this
I have this storyboard in MainPage.xaml
<Storyboard x:Name="SpinnerStoryboard">
<DoubleAnimation FillBehavior="HoldEnd"
RepeatBehavior="Forever"
Storyboard.TargetName="SpinnerTransform"
Storyboard.TargetProperty="Angle"
From="0"
To="360"
Duration="00:00:00.5" />
</Storyboard>
Also in MainPage.xaml.cs:
private void RefreshableScrollableContentPresenter_OnPullProgressChanged(object sender, RefreshProgressEventArgs e)
{
if (e.IsRefreshable)
{
if (e.PullProgress == 1)
{
// Progress = 1.0 means that the refresh has been triggered.
if (SpinnerStoryboard.GetCurrentState() == ClockState.Stopped)
SpinnerStoryboard.Begin();
}
else if (SpinnerStoryboard.GetCurrentState() != ClockState.Stopped)
SpinnerStoryboard.Stop();
else
{
// Turn the indicator by an amount proportional to the pull progress.
SpinnerTransform.Angle = e.PullProgress * 360;
}
}
}
and
private void RefreshableScrollableContentPresenter_OnRefreshRequested(object sender, RefreshRequestedEventArgs e)
{
var presenter = sender as RefreshableScrollableContentPresenter;
if (presenter != null)
{
using (var deferral = presenter.AutoRefresh ? e.GetDeferral() : null)
{
mainPageViewModel.ProductsViewModel.GetProductsCommand.Execute();
if (SpinnerStoryboard.GetCurrentState() != ClockState.Stopped)
SpinnerStoryboard.Stop();
}
}
}

How to show ProgressBar and make it progress?(Xamarin.Android)

I call a web service which gets 4 files, and while these files are loading I want to show progress to the user (circular or horizontal it doesn't matter). I've followed the examples on internet but nothing appears on screen.
MobileSellReference.Service1 service = new MobileSellReference.Service1();
service.Url = settings.Synchronization.Msellurl;
ProgressBar progressBar = FindViewById<ProgressBar>(Resource.Id.progressBar);
progressBar.Max = 100;
progressBar.Progress = 0;
byte[][] basedataResult = service.ToPPC(basedataZipName, objectId);
progressBar.IncrementProgressBy(25);
byte[][] dutybasedataResult = service.ToPPC(dutybasedataZipName, objectId);
progressBar.IncrementProgressBy(25);
byte[][] tranbasedataResult = service.ToPPC(tranbasedataZipName, objectId);
progressBar.IncrementProgressBy(25);
byte[][] vendbasedataResult = service.ToPPC(vendbasedataZipName, objectId);
progressBar.IncrementProgressBy(25);
I've found a lot of examples using external progressbar libraries but they all want to change the theme of the Activity. Instead I want some simple ProgressBar built into Xamarin.Android. For example when the first file is downloaded I want 1/4 of the circle to be filled, when 2 files are downloaded 1/2 of the circle to be filled et cetera. Similarly for a horizontal ProgressBar.
Use AsyncTask
.axml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/tv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="0" />
<ProgressBar
android:id="#+id/pb"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleHorizontal" />
</LinearLayout>
MainActivity:
public class MainActivity : Activity
{
ProgressBar pb;
TextView tv;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
pb = FindViewById<ProgressBar>(Resource.Id.pb);
tv = FindViewById<TextView>(Resource.Id.tv);
UpdatePB uptask = new UpdatePB(this,pb,tv);
uptask.Execute(100);
}
public class UpdatePB : AsyncTask<int, int, string>
{
Activity mcontext;
ProgressBar mpb;
TextView mtv;
public UpdatePB(Activity context,ProgressBar pb,TextView tv) {
this.mcontext = context;
this.mpb = pb;
this.mtv = tv;
}
protected override string RunInBackground(params int[] #params)
{
// TODO Auto-generated method stub
for (int i = 1; i <= 4; i++)
{
try
{
Thread.Sleep(3000);
}
catch (InterruptedException e)
{
// TODO Auto-generated catch block
Android.Util.Log.Error("lv",e.Message);
}
mpb.IncrementProgressBy(25);
PublishProgress(i * 25);
}
return "finish";
}
protected override void OnProgressUpdate(params int[] values)
{
mtv.Text = String.ValueOf(values[0]);
Android.Util.Log.Error("lv==", values[0] + "");
}
protected override void OnPostExecute(string result)
{
mcontext.Title = result;
}
}
}
This might be a helpful link:
https://developer.android.com/reference/android/widget/ProgressBar.html
Code:
<ProgressBar
android:id="#+id/determinateBar"
style="#android:style/Widget.ProgressBar.Horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:progress="25"/>
... and then you just change the progress; 25, 50, 75, 100?
After running into the same problem, I found another solution that got it working. I was reluctant to define a new class (like AsyncTask) to fix this, so looked into async await and threading. I found that after defining an Android.Widget.ProgressBar in an .axml layout file like so:
<ProgressBar
android:id="#+id/progressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progress="0"
style="?android:attr/progressBarStyleHorizontal" />
I could get it to update if I put the updating tasks in a System.Threading.Tasks.Task.Run and passing in an action that does the updates with RunOnUiThread call like:
btnDoStuff.Click += (sender, e) =>
{
Task.Run(() =>
{
RunOnUiThread(() =>
{
progressBar.Max = 100;
progressBar.Progress = 0;
progressBar.Visibility = ViewStates.Visible;
});
DoSomeWork1(arguments);
RunOnUiThread(() => progressBar.Progress += 25);
DoSomeWork2(arguments);
RunOnUiThread(() => progressBar.Progress += 25);
DoSomeWork3(arguments);
RunOnUiThread(() => progressBar.Progress += 25);
DoSomeWork4(arguments);
RunOnUiThread(() => progressBar.Progress += 25);
});
}
But even then I've had some inconsistent behavior - there may be an element of timing to it as well...

How to add text input field in cocos2d.Android cocos sharp?

I am trying to get CCTextFieldTTF to work in cocos sharp with Xamarin for an android application. But can't get hold of this for the life of me. Could not find any documentation on cocos sharp API either. Does anyone know how to use this class to render a text area in an android application? The reason I am asking is in a xamarin forum I saw someone saying that this does not work in the API yet. Any help would be highly appreciated. Thanks in advance.
I have this working in android
Here is the sample code:
Create a node to track the textfield
CCTextField trackNode;
protected CCTextField TrackNode
{
get { return trackNode; }
set
{
if (value == null)
{
if (trackNode != null)
{
DetachListeners();
trackNode = value;
return;
}
}
if (trackNode != value)
{
DetachListeners();
}
trackNode = value;
AttachListeners();
}
}
//create the actual input textfield
var textField = new CCTextField(string.Empty, "Somefont", 25, CCLabelFormat.SystemFont);
textField.IsColorModifiedByOpacity = false;
textField.Color = new CCColor3B(Theme.TextWhite);
textField.BeginEditing += OnBeginEditing;
textField.EndEditing += OnEndEditing;
textField.Position = new CCPoint (0, 0);
textField.Dimensions = new CCSize(VisibleBoundsWorldspace.Size.Width - (160 * sx), vPadding);
textField.PlaceHolderTextColor = Theme.TextYellow;
textField.PlaceHolderText = Constants.TextHighScoreEnterNamePlaceholder;
textField.AutoEdit = true;
textField.HorizontalAlignment = CCTextAlignment.Center;
textField.VerticalAlignment = CCVerticalTextAlignment.Center;
TrackNode = textField;
TrackNode.Position = pos;
AddChild(textField);
// Register Touch Event
var touchListener = new CCEventListenerTouchOneByOne();
touchListener.OnTouchBegan = OnTouchBegan;
touchListener.OnTouchEnded = OnTouchEnded;
AddEventListener(touchListener);
// The events
bool OnTouchBegan(CCTouch pTouch, CCEvent touchEvent)
{
beginPosition = pTouch.Location;
return true;
}
void OnTouchEnded(CCTouch pTouch, CCEvent touchEvent)
{
if (trackNode == null)
{
return;
}
var endPos = pTouch.Location;
if (trackNode.BoundingBox.ContainsPoint(beginPosition) && trackNode.BoundingBox.ContainsPoint(endPos))
{
OnClickTrackNode(true);
}
else
{
OnClickTrackNode(false);
}
}
public void OnClickTrackNode(bool bClicked)
{
if (bClicked && TrackNode != null)
{
if (!isKeyboardShown)
{
isKeyboardShown = true;
TrackNode.Edit();
}
}
else
{
if (TrackNode != null)
{
TrackNode.EndEdit();
}
}
}
private void OnEndEditing(object sender, ref string text, ref bool canceled)
{
//((CCNode)sender).RunAction(scrollDown);
Console.WriteLine("OnEndEditing text {0}", text);
}
private void OnBeginEditing(object sender, ref string text, ref bool canceled)
{
//((CCNode)sender).RunAction(scrollUp);
Console.WriteLine("OnBeginEditing text {0}", text);
}
void AttachListeners()
{
// Attach our listeners.
var imeImplementation = trackNode.TextFieldIMEImplementation;
imeImplementation.KeyboardDidHide += OnKeyboardDidHide;
imeImplementation.KeyboardDidShow += OnKeyboardDidShow;
imeImplementation.KeyboardWillHide += OnKeyboardWillHide;
imeImplementation.KeyboardWillShow += OnKeyboardWillShow;
imeImplementation.InsertText += InsertText;
}
void DetachListeners()
{
if (TrackNode != null)
{
// Remember to remove our event listeners.
var imeImplementation = TrackNode.TextFieldIMEImplementation;
imeImplementation.KeyboardDidHide -= OnKeyboardDidHide;
imeImplementation.KeyboardDidShow -= OnKeyboardDidShow;
imeImplementation.KeyboardWillHide -= OnKeyboardWillHide;
imeImplementation.KeyboardWillShow -= OnKeyboardWillShow;
imeImplementation.InsertText -= InsertText;
}
}
This is all taken from the link below but needed a bit of additional work to get it working on each platform.
https://github.com/mono/cocos-sharp-samples/tree/master/TextField

How to add a copy/paste context menu to browser element in XULRunner?

I would like to allow the user of my XULRunner based app to be able to do copy/paste via a context menu.
Keyboard shortcuts Ctrl-C and Ctrl-V are already working fine
Here it is without flash. The getInputSelection function is from here: Is there an Internet Explorer approved substitute for selectionStart and selectionEnd?.
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="mywin" title="my app"
width="800" height="600" persist="screenX screenY width height sizemode"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<popupset>
<menupopup id="clipmenu">
<menuitem label="Copy" oncommand="copy()"/>
<menuitem label="Paste" oncommand="paste();"/>
</menupopup>
</popupset>
<browser
type="content-primary"
src="http://127.0.0.1/"
flex="1"
disablehistory="true"
id="browserId"
context="clipmenu"
/>
<script>
<![CDATA[
function copy()
{
var tabBrowser = document.getElementById("browserId");
var selectedTagName = tabBrowser.contentWindow.document.activeElement.tagName;
var windowObj;
if(selectedTagName == "IFRAME")
{
windowObj = tabBrowser.contentWindow.frames[tabBrowser.contentWindow.document.activeElement.name];
}
else
{
windowObj = document.getElementById("browserId").contentWindow;
}
var selectedText = windowObj.getSelection();
if(!selectedText || selectedText == "")
{
var focused = windowObj.document.activeElement;
if(focused && focused.value)
{
selectedText = getSelectionFromInput(focused);
}
}
//alert(selectedText + "---");
const clipHelper = Components.classes["#mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper);
clipHelper.copyString(selectedText);
}
function getSelectionFromInput(focused)
{
var focusedValue = focused.value;
var sel = getInputSelection(focused);
var selectedText = "";
if(focusedValue.length == (sel.end))
{
selectedText = focusedValue.substring(sel.start);
}
else
{
selectedText = focusedValue.substring(sel.start, (sel.end));
}
return selectedText;
}
function paste()
{
var clip = Components.classes["#mozilla.org/widget/clipboard;1"].getService(Components.interfaces.nsIClipboard);
var trans = Components.classes["#mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
trans.addDataFlavor("text/unicode");
clip.getData(trans, clip.kGlobalClipboard);
var str = new Object();
var len = new Object();
trans.getTransferData("text/unicode",str,len);
str = str.value.QueryInterface(Components.interfaces.nsISupportsString);
str = str.data.substring(0, len.value / 2);
var focused = document.commandDispatcher.focusedElement;
var focusedValue = focused.value;
var sel = getInputSelection(focused);
focused.value = focusedValue.substring(0,sel.start) + str + focusedValue.substring(sel.end);
}
function getInputSelection(el) {
var start = 0, end = 0, normalizedValue, range,
textInputRange, len, endRange;
if (typeof el.selectionStart == "number" && typeof el.selectionEnd == "number") {
start = el.selectionStart;
end = el.selectionEnd;
} else {
range = document.selection.createRange();
if (range && range.parentElement() == el) {
len = el.value.length;
normalizedValue = el.value.replace(/\r\n/g, "\n");
// Create a working TextRange that lives only in the input
textInputRange = el.createTextRange();
textInputRange.moveToBookmark(range.getBookmark());
// Check if the start and end of the selection are at the very end
// of the input, since moveStart/moveEnd doesn't return what we want
// in those cases
endRange = el.createTextRange();
endRange.collapse(false);
if (textInputRange.compareEndPoints("StartToEnd", endRange) > -1) {
start = end = len;
} else {
start = -textInputRange.moveStart("character", -len);
start += normalizedValue.slice(0, start).split("\n").length - 1;
if (textInputRange.compareEndPoints("EndToEnd", endRange) > -1) {
end = len;
} else {
end = -textInputRange.moveEnd("character", -len);
end += normalizedValue.slice(0, end).split("\n").length - 1;
}
}
}
}
return {
start: start,
end: end
};
}
]]>
</script>
</window>
Updated to support iframes.
Create menu using the code below.
<popupset>
<menupopup id="clipmenu">
<menuitem label="Copy" oncommand="copy();"/>
<menuseparator/>
<menuitem label="paste" oncommand="paste();"/>
</menupopup>
</popupset>
<browser type="content" src="chrome://myapp/content/theme1/index.html" flex="1" context="clipmenu"/>
Connect it to whatever you want, here am making it the context menu of the browser element by giving the id of menu in the context attribute of the browser element.
Then for each menu you can give the command to execute in oncommand event. We have given the function copy and paste.
Then write the code to copy text from whatever element you want or if you want to copy the selected data only.
See the below link for copying command.
http://www.deluxeblogtips.com/2010/06/javascript-copy-to-clipboard.html
One more example for "Copy" context menu in XULRunner under SWT Browser (code was implemented for Eclipse v3.5.1, XULRunner v1.8.1.3):
Browser browser = new Browser(parent, style | SWT.MOZILLA);
Menu menu = new Menu(browser);
MenuItem item = new MenuItem(menu, SWT.NONE);
item.setText("Copy");
item.addSelectionListener(new SelectionListener() {
#Override
public void widgetSelected(SelectionEvent e) {
nsIWebBrowser webBrowser = (nsIWebBrowser) browser.getWebBrowser();
nsIInterfaceRequestor req = (nsIInterfaceRequestor) webBrowser.queryInterface(nsIInterfaceRequestor.NS_IINTERFACEREQUESTOR_IID);
nsIDocShell docShell = (nsIDocShell) req.getInterface(nsIDocShell.NS_IDOCSHELL_IID);
nsIClipboardCommands cmds = (nsIClipboardCommands) docShell.queryInterface(nsIClipboardCommands.NS_ICLIPBOARDCOMMANDS_IID);
cmds.copySelection();
}
#Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
browser.setMenu(menu);

Resources