FAQ Database Discussion Community


Outline a raster cell of interest by cell number

r,plot,selection,cell,raster
I would like to outline a raster cell given the cell number in a plot. I have made a simplified example, that I was able to make in power point, but may have a resolution that will be more difficult to do this for (720 x 360 vs 3 x...

Sorting a list in Python containing tuples with Selection Sort

python,sorting,selection
I would like to sort the following list using selection sort: list1 = [(1,2,3),(3,6,4),(4,7,9)] How can I sort the above by the second element of each tuple (2,6,7) ? I have the following code for a normal selection sort, but I do now know how to do it with tuples....

R: Choosing specific number of combinations from all possible combinations

r,selection,combinations
Let's say we have the following dataset set.seed(144) dat <- matrix(rnorm(100), ncol=5) The following function creates all possible combinations of columns and removes the first (cols <- do.call(expand.grid, rep(list(c(F, T)), ncol(dat)))[-1,]) # Var1 Var2 Var3 Var4 Var5 # 2 TRUE FALSE FALSE FALSE FALSE # 3 FALSE TRUE FALSE FALSE...

Convert PictureBox Selection Rectangle according to SizeMode

c#,selection,picturebox,coordinate-systems
I have two PictureBoxes pbOriginal and pbFace. After Selecting a "face" from an image in pbOriginal I clone the rectangle selection and place it into pbFace. However, Because pbOriginal is using SelectionMode=Stretch the actual area being copied is not the same as the area being selected. How do I convert...

Select n rows after specific number

r,selection,rows
I work with a data.frame like this: Country Date balance_of_payment business_confidence_indicator consumer_confidence_indicator CPI Crisis_IMF 1 Australia 1980-01-01 -0.87 100.215 99.780 25.4 0 2 Australia 1980-04-01 -1.62 100.061 99.746 26.2 0 3 Australia 1980-07-01 -3.70 100.599 100.049 26.6 0 4 Australia 1980-10-01 -3.13 100.597 100.735 27.2 0 5 Australia 1981-01-01 -2.73...

How to rotate selected QGraphicsItems around the selection center?

qt,rotation,selection,qgraphicsitem
I would like to implement rotation of selected items. I have noticed that there are 2 functions - rotate() which performs an immediate action but does not save the rotation on the item - and setRotation(), which stores rotation() (though it requires a repaint causing event). If I select a...

Select all node that has certain css-rule without jQuery

javascript,css,selection
How to get all nodes that have certain CSS rule, for example if defined: html { color: blue; } div.x { color: blue; } And I want to get all node that has color: blue, I want to get the html (document.children[0]) and all div with class='x' node only, not...

AngularJS if user chooses year/month/week resolution on Dropdown1, populate Dropdown2 with the corresponding values

angularjs,drop-down-menu,user,selection
I am new to AngularJS and I'm trying to figure out how to do the following task: Say that we have a dropdown (Dropdown1) that includes the options {year, month, week, day}. We also have Dropdown2, that changes according to what is chosen in Dropdown1. So if user chooses 'year',...

JavaFX TableView change selected cell colour

css,javafx,tableview,selection,tablecell
I have a JavaFX TableView and a ListView and they both use custom cell factories. In particular I have overridden updateItem method in order to bind a particular CSS class based on cell value. This is part of my CSS file: .tissueCell { -fx-text-fill: #F5AD11; } .tissueCell:selected { -fx-background-color: #F5AD11;...

Get attributes of selected text in JTextPane

java,attributes,selection,jtextpane,caret
I'm trying to find out, how to get attributes of selected text in JTextPane. I found that best solution is do it with getInputAttributes() and CaretListener. But I have some issues with this implementation. My solution showing attributes of text on last position of caret, but not on actual position...

How to prevent selection of SeparatorList.Separator in a JList?

java,override,selection,jlist,glazedlists
I have created a JList using GrazedLists, specifically an EventList which I then pass into a SeparatorList with a custom Comparator that sorts my EventList elements. I am using a DefaultEventListModel as the JList model, passing in my SeparatorList. And I am using a custom CellRenderer to decorate the SeparatorList.Separator...

EXTJS tree panel disable selection change

javascript,extjs,selection,treepanel
I have tree panel: xtype : 'treepanel', itemId : 'field-tree-command-metas', region : 'center', hideHeaders : true, rootVisible : false, emptyText : 'No Commands Available', deferEmptyText : true, bufferedRenderer : false, reference : 'treeCommandMetas', bind : { selection : '{bindSelection}' }, listeners : { boxready : function() { var treeView =...

three.js merge geometry and octree selection

merge,three.js,geometry,selection,octree
I am using Three.js to show a number of custom geometry's in various positions and rotations. They are static and rarely change, but the user can add, delete or change the shape of each individual object. This has worked well using the code snippet below: var Mat=new THREE.MeshBasicMaterial( { color:...

actionscript 3 - random object selection

actionscript-3,random,selection
So I want a unit to be able to randomly target a player unit or a players allies. I have all ally ships stored in an array and the player is on the stage separately. Here is the code for the bullet creation, with the irrelevant stuff removed. private function...

How can I get the text style from window.selection()?

javascript,html,css,dom,selection
I'm trying to get the css style of the text selection when user select only 1 row. This is my code which works for multiple lines selection case: var selectedDivs = window.selection().getRangeAt(0).cloneContent().children // Then I can get css style from selectedDivs But for single line selection, the selectedDivs is always...

How to select a column of a JTable in JDialog by selecting a header

java,swing,jtable,selection,jtableheader
What I've been trying to do with a JDialog are... To select a column of JTable by clicking the header To check which column is selected by the user To get the value of the cells inside the column According to this post and this page , it would...

flot selection / highlighting - need to have simple value, not range

selection,flot,highlight
I have a flot chart and need to select / highlight one value. Selection requires to set "from-to" range, is it easy to do with static data, but when data set is changed from 0..0.1 till 0..100000 I have to calculate this range to set range to show as line....

VBA: access sheet from userForm

excel,vba,selection,cell,active
I am trying to access my workbook and sheets while I am in a subroutine of my UserForm. My macro starts when the focus in the worksheet is changed: Sub Worksheet_SelectionChange(ByVal Target As Range) '... End Sub In my UserForm, I now wanted to define what happens when the red...

Primefaces Selected Row is not set

primefaces,datatable,selection
I did try lots of ways but couldnt find a solution for my problem. My problem is , clicking the button of the selected row to view dialog doesnt set the selecteduser object. It seems null. Thank you for your time. Here is my xhtml page. <ui:composition template="/pages/admin/admin.xhtml" xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"...

How to save select option in localStorage with jQuery?

jquery,storage,selection,local
I am trying to save selected option in localStorage in HTML, so if you refresh page, the selection stays selected. I have try this: HTML: <select id="edit"> <option>1</option> <option>2</option> <option>3</option> </select> jQuery: $(function() { $('#edit').change(function() { localStorage.setItem('todoData', this.innerHTML); }); if(localStorage.getItem('todoData')){ localStorage.getItem('todoData'); } }); But this seems not to work, any...

selection menu for iframe src using javascript

javascript,html,iframe,selection,src
I found out how to use javascript to change the iframe src, but when I made a selection menu that allows you to choose the url to load in, it only loads the first option in the menu, even when you select a different url. I got it to work...

Qt: how to detect whether a widget is selected?

c++,qt,widget,focus,selection
I didn't see any signal/slot/function that could tell me whether a widget is selected by mouse? Is it possible to have such an function to tell me whether the current QWidget is selected? And How could I differentiate between "the current widget is selected" and "one of its child widget...

Prevent change of selection in ListView

c#,xaml,listview,selection
I have a ListView. I want to prevent changing selection. <ListView SelectionMode="Single" MinHeight="400" ItemsSource="{Binding Partners}" SelectedItem="{Binding SelectedPartner, Mode=TwoWay}"> <ListView.View> <GridView> <Header="ID" DisplayMemberBinding="{Binding partnerId}"/> </GridView> </ListView.View> </ListView> and I have in ViewModel: public Partner SelectedPartner { get { return _selectedPartner; } set { if (_selectedPartner == null) //when it isn't selected...

Xamarin.Forms ListView custom cell is not selectable

listview,selection,xamarin.forms
I created a custom cell: public class TextCell2 : ViewCell { public TextCell2() { View = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { new Label { Text = "Test" }, new Button { Text = "Test 2" } } }; } } If I don't...

Triple Conditioned selection of data in r

r,selection,condition
I am expanding a question asked 5 months ago: Double Conditioned selection of data in r I need to add a condition now and I cannot do it on the suggested solution. Apparentely my coding skill have not improved much :/ reproducible example: time.stamp <- c(1:22) behavior <- c("close", "1","2","1","1",...

Interactive Selection highlighting of text inside the browser

javascript,jquery,selection,highlight,interactive
what I need is interactive selection highlighting of text in the browser via Javascript. To be more specific, lets just say I have a bunch of text in a div element like so: <div>The quick brown fox jumps over the lazy dog ... </div> Now what I want to do...

How to run a method in multiple worksheets without actively selecting each one

vba,excel-vba,methods,selection
I am having trouble writing some code in VBA that will run a macro for all of the sheets in an active workbook without 'manually' selecting the sheets each time and then running the method again. What I currently have is as follows: sub NhlStatsHighlighter() Dim ws As Worksheet For...

Textbox doesn't keep selection on binded list update

c#,wpf,textbox,selection
In my ViewModel i've got an ObservableCollection of string that contains all messages received from ethernet: public ObservableCollection<string> Messages { get; set; } And i binded it to a texbox in the view with a converter: <TextBox Text="{Binding Messages, Converter={StaticResource ListToStringConverter}}" HorizontalAlignment="Center"/> my converter is a simple string finalStr; foreach(var...

Setting and getting selectionrange/caret position in contenteditable div element (dart)

dart,selection,contenteditable,caret
I'm trying to swith from using a textarea element for my editor to a <div contenteditable="true"></div> element. I have only one problem that is that I can't use textarea.selectionStart, textarea.selectionEnd, textarea.setSelectionRange() anymore. Are there any method to get and set the selection range for a div element in dart ?...

Insert at caret with javascript, but only within a certain class

javascript,range,selection
I'm using a bit of javascript written by The Great and Powerful Oz Tim Down that inserts things at the caret. It works great, but how can I restrict the function to only operate within a div with a class name of "editor-text"? Edit: It must also work within other...

C# | How Do I Select a Word or Tag in a TextBox by Mouse Location?

c#,winforms,textbox,tags,selection
In Windows Forms, if you double click on a word in a textbox, say with text "Do you want to play a game?", the textbox has the uncanny behaviour of selecting a word and the space after it. It gets worse if you want to select a tag in text...

Selectioncolor doesn't work within KeyPress event

c#,winforms,colors,selection,keypress
I'm trying to change the color of some text when Ctrl+Z is pressed as the following: private void richTextBox1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Z && (e.Control)) { if (undoList.Count > 0) { ignoreChange = true; richTextBox1.Text = undoList[undoList.Count - 1]; //richTextBox1.Focus(); richTextBox1.SelectionStart = 3; richTextBox1.SelectionLength = 2;...

Selection problems after Bio Format Importer, czi and zvi Files, ImageJ

plugins,selection,imagej
Hello I'm using ImageJ to analyse -czi and -zvi files. I'm using an automatic selection with "create selection" or "analyze particle"s. It's working well when openening/importing the files with ImageJ. But when I try to use the Bio-Format importer Plugin with the same pictures, it's not working. Not my intended...

Multiple SelectionBackColors for a Datagridview or Disabling the Color

vb.net,datagridview,selection,highlighting
I'm trying to change the dgv selectionbackcolor depending on the selected cell's backcolor, so if the cell's backcolor is light red, the selectionbackcolor of that cell will be dark red. I have a solution for single cell selection, but my problem is I have several different cell colors and when...

I need to delete the last 7 characters of a specific range of cells that are already selected

vba,delete,selection
I'm trying to remove the last 7 characters, which are jibberish in a report i run, but only for the cells i have selected in the spreadsheet. i keep on getting a Run-Time Error 13 though. Sub Mitts() With Selection .Value = Left(.Value, Len(.Value) - 7) End With End Sub...

How can I change automatically the selected item in a ListView?

android,android-listview,selection
I've a ListView with some items that users can select. I want that the first element appears selected, and after 1 or 2 seconds, the selected item will be the second automatically. How can I do this? When a item is selected, it can has a bold text for example....

Android. How do I keep a button displayed as PRESSED until the action created by that button is finished? Activated/Selected not usable

android,button,selection,remoteview
I want to keep a ImageButton with a state-list drawable in a "Wait-for-Action-Finished" state as long the action was not done. I've seen the other topics around this problem. But in my case the other solutions are not working for me because: I'm using the layout (which contains the buttons)...

Alternative for g:select (multiple values)

javascript,jquery,grails,selection
I have a Domain Class Project with a one-to-many property users : static hasMany = [users: User] In my scaffolding code the view is created with: <div class="fieldcontain ${hasErrors(bean: projectInstance, field: 'users', 'error')} "> <label for="users"> <g:message code="project.users.label" default="Users" /> </label> <g:select name="users" from="${usermanagement.User.list()}" multiple="multiple" optionKey="id" size="5" value="${projectInstance?.users*.id}" class="many-to-many"/> </div>...

Android RecyclerView select first Item

android,selection,recyclerview,highlighting
I'm using a RecyclerView to implement a NavigationDrawer. I got click events working, but I can't figure out how to have the first item selected on App start and following that keep the selected item higlighted even if the drawer is not shown. All I've been able to find is...

Can Javascript get a selection from outside the browser?

javascript,selection
How can a Javascript script running within a browser obtain a window system selection from a region outside the browser? For example, in scan mode, StarDict, a Java program not running in a browser, responds to a selection event in, say, an xterm or pdf viewer, by looking up the...

how to prevent unclearing a textbox when selection is made?

javascript,onclick,textarea,selection
I'm trying to build a texteditor and for that I'm using a textarea to fill in my text My problem is when I click a button the textarea selection is gone. Here is some code to show the problem: <!DOCTYPE html> <html> <body> Address:<br> <textarea id="myTextarea"> California Road </textarea> <p>Click...

Refresh selection model of p:datatable on row deselection

jsf,primefaces,datatable,selection
I have a problem with the selection model of a Primefaces 5.0 datatable. This selection model does not process deselection properly: Selection of rows adds these roles as expected to the list of selected rows. But a deselection has no influence on this list; deselected rows remains in it. Only...

Jquery - Jquery 2 dropdown lists, remove 1st selected option from 2nd list

jquery,selection,dropdownbox
I'm using this code to allow me to select an entry from dropdown 1 and the same entry is removed from dropdown 2. $("#BoxName").change(function(){ var selectedItem = $(this).val(); var nextDropdown = $(this).parent("td").next("td").find("select.BoxComparisonClass"); $(nextDropdown).find("option").show(); $(nextDropdown).find("option:[value="+selectedItem+"]" ).hide(); }) This can be seen working HERE : http://jsfiddle.net/8kvesskv/5/ This works fine in Chrome &...

Basic D3 - Working with arrays inside objects

arrays,object,d3.js,selection
I'm pretty new to D3 and I'm stuck right now in a particular subject that I suppose it's very basic. I've been researching the whole day for something that could help me but everything I've found ended up not being exactly what I need, anyway I apologize from now if...

Keeping only some rows of a matrix using one column as choice-maker in R

r,matrix,selection,rows
I have a matrix in R and I would like to keep only some rows of it according to a column. For example, if I have the matrix A shown here 1 2 5 6 8 1 3 4 5 7 8 8 6 7 7 9 8 8 5...

Move to the end one character with rangy

javascript,range,selection,contenteditable,rangy
I have a contenteditable div, I want to move the range just one character after the current one. I currently want to check if the character after caret is a certain character, and if it is then place caret after it I use this code but it don't work placeCaretAfterHiddenCharacter:function(containerEl,afterCharacters)...

If the median of medians algorithm doesn't change the avg-case complexity of quicksort, why use it?

algorithm,sorting,selection,quicksort
Given the hard lower bound on the sorting algorithm's average case complexity Omega(n*lg(n)), when/why would you decide to spend the time implementing this selection algorithm with quicksort rather than just using a random pivot or just the simple (n/2)th position in the array?

How can I prevent removing the selection from text after a click?

javascript,events,text,click,selection
I'm working on an admin-panel where the inputs are contenteditable divs. I also have a toolbar (containing some formatting buttons), that shows up if you have any selected text inside the div, and will be removed if not. The problem is, that when I click to any button in the...

How to use Angular ng-options other than on a select element?

javascript,html,angularjs,selection
The official docs say that we can use ng-options on any element, not just the select. I figure we can do this so that we can make the selection UI look better (especially if we want to display a thumbnail image or provide more info than just from one property)....

Selection Of data using “as” clause Using JPA

java,oracle,jpa,selection,clause
As I know, using SQL we can select the data with customised form like the query below: select '<Root value=\"'"|| databaseColumnValue || '\"'" as displayItem from Table"; The selected value looks like below: <Root value = 10 /> I have tried many ways in JPA to achieve this and haven't...

Trouble With Selection Object in Firefox and IE

javascript,selection
I've got some javascript that messes with selections. The full code does some complicated stuff that I'd rather not go into right now, but I've got a smaller test case I don't understand here. If you load this page you should see some text and two buttons. Double click on...

JTable setRowSelectionInterval has no effect for JButton

java,swing,jtable,selection
Using a JTable, my Table Model setValueAt() method moves the selection to the next row in certain cases, using setRowSelectionInterval() and setColumnSelectionInterval(). When it's called from the (default) cell editor (by user typing in the cell and hitting tab), the code works: the desired next cell is selected (the first...

Disable selection based on previous Dropdown menu selection

javascript,jquery,html,drop-down-menu,selection
Ran into a problem that is causing some snags. I am making a product configurator for my company. Essentially, all of our products are custom, so different components may not be compatible with other components. What I am trying to do is disable selections on different dropdown menus based on...

How do I copy an HTML document and edit the copy based upon the selection, without altering the original document?

javascript,html,dom,range,selection
I have an HTML document, and I would like to remove some of the tags from it dynamically using Javascript, based on whether the tags are within the current selection or not. However, I do not want to update the actual document on the page, I want to make a...