Search Results

Search found 7466 results on 299 pages for 'selected'.

Page 17/299 | < Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >

  • Use javascript to extend a DOM Range to cover partially selected nodes

    - by ko-dos
    I'm working on a rich text editor like web application, basically a XML editor written in javascript. My javascript code needs to wrap a selection of nodes from the contentEditable div container. I'm using the methods described at MDC. But since I need to synchronize the div containers content to my XML DOM I would like to avoid partial selections as described in w3c ranges: <BODY><H1>Title</H1><P>Blah xyz.</P></BODY ............^----------------^............ This selection starts inside H1 and ends inside P, I'd like it to include H1,P completely. Is there an easy way to extend the selection to cover partially selected children completely? (The code doesn't need to work with opera/IE)

    Read the article

  • Get items selected from another form

    - by Samarth Agarwal
    Hi I have a Windows Form application. I have a Textbox. I want to implement a functionality like when the user clicks on the textbox, a list should be made available to the user and then the item selected from the list should be filled in the textbox. The list should not be available if some other control is focussed other than the textbox. What would be the better way to do this? Should I implement the list in the same form as the textbox or should I use another form for the list? I want to implement a functionality like in the Tally Accounting Software.

    Read the article

  • Grid View selected index

    - by user2924573
    I have a grid which contains a edit button . When i click the edit button and debug it does not hit to the selected index change event . There are no build errors code behind the grid public void btnModemDetailsEdit_Click(object sender, EventArgs e) { isEdit = true; } protected void gridModemDetails_SelectedIndexChanged(object sender, EventArgs e) { int id = Convert.ToInt32(GridModemDetails.DataKeys[GridModemDetails.SelectedIndex].Values["gridModemDetails_SelectedIndexChanged"].ToString()); } <asp:GridView ID="GridModemDetails" runat="server" Width="435px" DataKeyNames="ModemId" AllowPaging="True" OnSelectedIndexChanged="gridModemDetails_SelectedIndexChanged" AutoGenerateColumns="False"> <Columns> <asp:TemplateField HeaderText="Edit" Visible="True" > <ItemTemplate> <asp:LinkButton ID="btnModemDetailsEdit" AccessibleHeaderText="Edit" ButtonType="Button" Text="Edit" HeaderText="Edit" runat="server" OnClick="btnModemDetailsEdit_Click" runat="server"/> </ItemTemplate> </asp:TemplateField>

    Read the article

  • jQuery - Set selected value of all dropdowns on page

    - by Tgibson
    Hello Frieds, I have another jQuery question. For a user control with lots of database activity, I would like to use jQuery to set the selected values of all of the dropdowns to their "current" value. I want to do this to make the page appear to have finished the database call. My jQuery skill is not the best, but I believe I need to use the pageLoad(). And since each dropdown is inside of a user control I can search for those dropdowns beginning with "usrControl" $('select[id ^="usrControl"'].each(function(){ var selectedValue = $(this).val() $(this).val(selectedValue) }); Something like this is what I have in mind. Thanks

    Read the article

  • Why keylistener is not working here?

    - by swift
    i have implemented keylistener interface and implemented all the needed methods but when i press the key nothing happens here, why? package swing; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GridLayout; import java.awt.Point; import java.awt.RenderingHints; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.image.BufferedImage; import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLayeredPane; import javax.swing.JPanel; import javax.swing.JTextArea; class Paper extends JPanel implements MouseListener,MouseMotionListener,ActionListener,KeyListener { static BufferedImage image; String shape; Color color=Color.black; Point start; Point end; Point mp; Button elipse=new Button("elipse"); int x[]=new int[50]; int y[]=new int[50]; Button rectangle=new Button("rect"); Button line=new Button("line"); Button roundrect=new Button("roundrect"); Button polygon=new Button("poly"); Button text=new Button("text"); ImageIcon erasericon=new ImageIcon("images/eraser.gif"); JButton erase=new JButton(erasericon); JButton[] colourbutton=new JButton[9]; String selected; Point label; String key; int ex,ey;//eraser //DatagramSocket dataSocket; JButton button = new JButton("test"); JLayeredPane layerpane; Point p=new Point(); int w,h; public Paper() { JFrame frame=new JFrame("Whiteboard"); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(640, 480); frame.setBackground(Color.black); layerpane=frame.getLayeredPane(); setWidth(539,444); setBounds(69,0,555,444); layerpane.add(this,new Integer(2)); layerpane.add(this.addButtons(),new Integer(0)); setLayout(null); setOpaque(false); addMouseListener(this); addMouseMotionListener(this); setFocusable(true); addKeyListener(this); System.out.println(isFocusable()); setBorder(BorderFactory.createLineBorder(Color.black)); } public void paintComponent(Graphics g) { try { super.paintComponent(g); g.drawImage(image, 0, 0, this); Graphics2D g2 = (Graphics2D)g; if(color!=null) g2.setPaint(color); if(start!=null && end!=null) { if(selected==("elipse")) g2.drawOval(start.x, start.y,(end.x-start.x),(end.y-start.y)); else if(selected==("rect")) g2.drawRect(start.x, start.y, (end.x-start.x),(end.y-start.y)); else if(selected==("rrect")) g2.drawRoundRect(start.x, start.y, (end.x-start.x),(end.y-start.y),11,11); else if(selected==("line")) g2.drawLine(start.x,start.y,end.x,end.y); else if(selected==("poly")) g2.drawPolygon(x,y,2); } } catch(Exception e) {} } //Function to draw the shape on image public void draw() { Graphics2D g2 = image.createGraphics(); g2.setPaint(color); if(start!=null && end!=null) { if(selected=="line") g2.drawLine(start.x, start.y, end.x, end.y); else if(selected=="elipse") g2.drawOval(start.x, start.y, (end.x-start.x),(end.y-start.y)); else if(selected=="rect") g2.drawRect(start.x, start.y, (end.x-start.x),(end.y-start.y)); else if(selected==("rrect")) g2.drawRoundRect(start.x, start.y, (end.x-start.x),(end.y-start.y),11,11); else if(selected==("poly")) g2.drawPolygon(x,y,2); } if(label!=null) { JTextArea textarea=new JTextArea(); if(selected==("text")) { textarea.setBounds(label.x, label.y, 50, 50); textarea.setMaximumSize(new Dimension(100,100)); textarea.setBackground(new Color(237,237,237)); add(textarea); g2.drawString("key",label.x,label.y); } } start=null; repaint(); g2.dispose(); } public void text() { System.out.println(label); } //Function which provides the erase functionality public void erase() { Graphics2D pic=(Graphics2D) image.getGraphics(); Color erasecolor=new Color(237,237,237); pic.setPaint(erasecolor); if(start!=null) pic.fillRect(start.x, start.y, 10, 10); } //To set the size of the image public void setWidth(int x,int y) { System.out.println("("+x+","+y+")"); w=x; h=y; image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); } //Function to add buttons into the panel, calling this function returns a panel public JPanel addButtons() { JPanel buttonpanel=new JPanel(); buttonpanel.setMaximumSize(new Dimension(70,70)); JPanel shape=new JPanel(); JPanel colourbox=new JPanel(); shape.setLayout(new GridLayout(4,2)); shape.setMaximumSize(new Dimension(70,140)); colourbox.setLayout(new GridLayout(3,3)); colourbox.setMaximumSize(new Dimension(70,70)); buttonpanel.setLayout(new BoxLayout(buttonpanel,BoxLayout.Y_AXIS)); elipse.addActionListener(this); elipse.setToolTipText("Elipse"); rectangle.addActionListener(this); rectangle.setToolTipText("Rectangle"); line.addActionListener( this); line.setToolTipText("Line"); erase.addActionListener(this); erase.setToolTipText("Eraser"); roundrect.addActionListener(this); roundrect.setToolTipText("Round rect"); polygon.addActionListener(this); polygon.setToolTipText("Polygon"); text.addActionListener(this); text.setToolTipText("Text"); shape.add(elipse); shape.add(rectangle); shape.add(line); shape.add(erase); shape.add(roundrect); shape.add(polygon); shape.add(text); buttonpanel.add(shape); for(int i=0;i<9;i++) { colourbutton[i]=new JButton(); colourbox.add(colourbutton[i]); if(i==0) colourbutton[0].setBackground(Color.black); else if(i==1) colourbutton[1].setBackground(Color.white); else if(i==2) colourbutton[2].setBackground(Color.red); else if(i==3) colourbutton[3].setBackground(Color.orange); else if(i==4) colourbutton[4].setBackground(Color.blue); else if(i==5) colourbutton[5].setBackground(Color.green); else if(i==6) colourbutton[6].setBackground(Color.pink); else if(i==7) colourbutton[7].setBackground(Color.magenta); else if(i==8) colourbutton[8].setBackground(Color.cyan); colourbutton[i].addActionListener(this); } buttonpanel.add(colourbox); buttonpanel.setBounds(0, 0, 70, 210); return buttonpanel; } public void mouseClicked(MouseEvent e) { if(selected=="text") { label=new Point(); label=e.getPoint(); draw(); } } @Override public void mouseEntered(MouseEvent arg0) { } public void mouseExited(MouseEvent arg0) { } public void mousePressed(MouseEvent e) { if(selected=="line"||selected=="erase"||selected=="text") { start=e.getPoint(); } else if(selected=="elipse"||selected=="rect"||selected=="rrect") { mp = e.getPoint(); } else if(selected=="poly") { x[0]=e.getX(); y[0]=e.getY(); } } public void mouseReleased(MouseEvent e) { if(start!=null) { if(selected=="line") { end=e.getPoint(); } else if(selected=="elipse"||selected=="rect"||selected=="rrect") { end.x = Math.max(mp.x,e.getX()); end.y = Math.max(mp.y,e.getY()); } else if(selected=="poly") { x[1]=e.getX(); y[1]=e.getY(); } draw(); } } public void mouseDragged(MouseEvent e) { if(end==null) end = new Point(); if(start==null) start = new Point(); if(selected=="line") { end=e.getPoint(); } else if(selected=="erase") { start=e.getPoint(); erase(); } else if(selected=="elipse"||selected=="rect"||selected=="rrect") { start.x = Math.min(mp.x,e.getX()); start.y = Math.min(mp.y,e.getY()); end.x = Math.max(mp.x,e.getX()); end.y = Math.max(mp.y,e.getY()); } else if(selected=="poly") { x[1]=e.getX(); y[1]=e.getY(); } repaint(); } public void mouseMoved(MouseEvent arg0) {} public void actionPerformed(ActionEvent e) { if(e.getSource()==elipse) selected="elipse"; else if(e.getSource()==line) selected="line"; else if(e.getSource()==rectangle) selected="rect"; else if(e.getSource()==erase) { selected="erase"; System.out.println(selected); erase(); } else if(e.getSource()==roundrect) selected="rrect"; else if(e.getSource()==polygon) selected="poly"; else if(e.getSource()==text) selected="text"; if(e.getSource()==colourbutton[0]) color=Color.black; else if(e.getSource()==colourbutton[1]) color=Color.white; else if(e.getSource()==colourbutton[2]) color=Color.red; else if(e.getSource()==colourbutton[3]) color=Color.orange; else if(e.getSource()==colourbutton[4]) color=Color.blue; else if(e.getSource()==colourbutton[5]) color=Color.green; else if(e.getSource()==colourbutton[6]) color=Color.pink; else if(e.getSource()==colourbutton[7]) color=Color.magenta; else if(e.getSource()==colourbutton[8]) color=Color.cyan; } @Override public void keyPressed(KeyEvent e) { System.out.println("pressed"); } @Override public void keyReleased(KeyEvent e) { System.out.println("key released"); } @Override public void keyTyped(KeyEvent e) { System.out.println("Typed"); } public static void main(String[] a) { new Paper(); } } class Button extends JButton { String name; public Button(String name) { this.name=name; } public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D)g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //g2.setStroke(new BasicStroke(1.2f)); if (name == "line") g.drawLine(5,5,30,30); if (name == "elipse") g.drawOval(5,7,25,20); if (name== "rect") g.drawRect(5,5,25,23); if (name== "roundrect") g.drawRoundRect(5,5,25,23,10,10); int a[]=new int[]{20,9,20,23,20}; int b[]=new int[]{9,23,25,20,9}; if (name== "poly") g.drawPolyline(a, b, 5); if (name== "text") g.drawString("Text",5, 22); } }

    Read the article

  • AutoCompleteTextView with custom list: how to set up onClick Listeners and getting the selected item

    - by steff
    Hi everyone, I am working on an app which uses tags. Accessing those should be as simple as possible. Working with an AutoCompleteTextView seems appropriate to me. What I want: existing tags should be displayed in a selectable list with a CheckBox on each item's side existing tags should be displayed UPON FOCUS of AutoCompleteTextView (i.e. not after typing a letter) What I've done so far is storing tags in a dedicated sqlite3 table. Tags are queried resulting in a Cursor. The Cursor is passed to a SimpleCursorAdapter which looks like this: Cursor cursor = dbHelper.getAllTags(); startManagingCursor(cursor); String[] columns = new String[] { TagsDB._TAG}; int[] to = new int[] { R.id.tv_tags}; SimpleCursorAdapter cursAdapt = new SimpleCursorAdapter(this, R.layout.tags_row, cursor, columns, to); actv.setAdapter(cursAdapt); As you can see I created *tags_row.xml* which looks like this: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingLeft="4dip" android:paddingRight="4dip" android:orientation="horizontal"> <TextView android:id="@+id/tv_tags" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:textColor="#000" android:onClick="actv_item_click" /> <CheckBox android:id="@+id/cb_tags" android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClick="actv_item_checked" /> </LinearLayout> It looks like this: So the results are displayed just as I'd want them to. But the TextView's onClick listener does not respond. And I don't have a clue on how to access the data once an item is (de-)selected. Behaviour of the list should be the following: tapping a CheckBox item should insert/append the corresponding tag into the AutoCompleteTextView (tags will be semicolon-seperated) tapping a TextView item should insert/apped the corresponding tag into the AutoCompleteTextView AND close the list. So please help me out. Thanks in advance, steff

    Read the article

  • Jqgrid: navigation based on the selected row

    - by bsreekanth
    Hello, I was trying to enable navigation based on a selected row. So, the user select a row from jQgrid, and when press the show (is there a show button for the grid, I saw edit, add etc), it needs to go to a new page based on the url (part of the row). $(document).ready(function () { function getLink() { // var rowid = $("#customer_list").jqGrid('getGridParam', 'selrow'); var rowid = $("#customer_list").getGridParam('selrow'); var MyCellData = $("#customer_list").jqGrid('getCell', rowid, 'dataUrl'); return MyCellData; } $("#customer_list").jqGrid({ url:'mytestList', editurl:'jq_edit_test', datatype: "json", colNames:['Call Id','Title','dataUrl'], colModel:[ {name:'callId', width:80, search:false }, {name:'title', width:200, sortable:false }, {name:'dataUrl',hidden:true} ], rowNum:10, sortname:'lastUpdated', sortorder: 'desc', pager:'#customer_list_pager', viewrecords: true, gridview: true }).navGrid('#customer_list_pager', {add:true,edit:true,del:false,search:true,refresh:true}, {closeAfterEdit:true, afterSubmit:afterSubmitEvent }, // edit options {addCaption:'Create New something', afterSubmit:afterSubmitEvent, savekey:[true,13]}, // add options {afterSubmit:afterSubmitEvent} // delete options ); $("#customer_list").jqGrid('filterToolbar'); }); so, the url is passed for each row as dataUrl. I'm trying to read it and set to the button. Whn debug through firebug, the rowid was 223 (there were only 12 rows in the grid), and the cell value is empty. Currently the button is kept outside the grid, but it may better to be it part of the vavGrid thanks.

    Read the article

  • how to change UITabbar selected color?

    - by RAGOpoR
    according to this post for now, Is apple will also reject this code? and how to implement what apple will approve? @interface UITabBar (ColorExtensions) - (void)recolorItemsWithColor:(UIColor *)color shadowColor:(UIColor *)shadowColor shadowOffset:(CGSize)shadowOffset shadowBlur:(CGFloat)shadowBlur; @end @interface UITabBarItem (Private) @property(retain, nonatomic) UIImage *selectedImage; - (void)_updateView; @end @implementation UITabBar (ColorExtensions) - (void)recolorItemsWithColor:(UIColor *)color shadowColor:(UIColor *)shadowColor shadowOffset:(CGSize)shadowOffset shadowBlur:(CGFloat)shadowBlur { CGColorRef cgColor = [color CGColor]; CGColorRef cgShadowColor = [shadowColor CGColor]; for (UITabBarItem *item in [self items]) if ([item respondsToSelector:@selector(selectedImage)] && [item respondsToSelector:@selector(setSelectedImage:)] && [item respondsToSelector:@selector(_updateView)]) { CGRect contextRect; contextRect.origin.x = 0.0f; contextRect.origin.y = 0.0f; contextRect.size = [[item selectedImage] size]; // Retrieve source image and begin image context UIImage *itemImage = [item image]; CGSize itemImageSize = [itemImage size]; CGPoint itemImagePosition; itemImagePosition.x = ceilf((contextRect.size.width - itemImageSize.width) / 2); itemImagePosition.y = ceilf((contextRect.size.height - itemImageSize.height) / 2); UIGraphicsBeginImageContext(contextRect.size); CGContextRef c = UIGraphicsGetCurrentContext(); // Setup shadow CGContextSetShadowWithColor(c, shadowOffset, shadowBlur, cgShadowColor); // Setup transparency layer and clip to mask CGContextBeginTransparencyLayer(c, NULL); CGContextScaleCTM(c, 1.0, -1.0); CGContextClipToMask(c, CGRectMake(itemImagePosition.x, -itemImagePosition.y, itemImageSize.width, -itemImageSize.height), [itemImage CGImage]); // Fill and end the transparency layer CGContextSetFillColorWithColor(c, cgColor); contextRect.size.height = -contextRect.size.height; CGContextFillRect(c, contextRect); CGContextEndTransparencyLayer(c); // Set selected image and end context [item setSelectedImage:UIGraphicsGetImageFromCurrentImageContext()]; UIGraphicsEndImageContext(); // Update the view [item _updateView]; } } @end

    Read the article

  • C# Winforms TabControl elements reading as empty until TabPage selected

    - by Geo Ego
    I have Winform app I am writing in C#. On my form, I have a TabControl with seven pages, each full of elements (TextBoxes and DropDownLists, primarily). I pull some information in with a DataReader, populate a DataTable, and use the elements' DataBindings.Add method to fill those elements with the current values. The user is able to enter data into these elements, press "Save", and I then set the parameters of an UPDATE query using the elements' Text fields. For instance: updateCommand.Parameters.Add("@CustomerName", SqlDbType.VarChar, 100).Value = CustomerName.Text; The problem I have is that once I load the form, all of the elements are apparently considered empty until I select each tab manually. Thus, if I press "Save" immediately upon loading the form, all of the fields on the TabPages that I have not yet selected try to UPDATE with empty data (not nice). As I select each TabPage, those elements will now send their data along properly. For the time being, I've worked out a (very) ugly workaround where I programmatically select each TabPage when the data is populated for the first time, but that's an unacceptable long-term solution. My question is, how can I get all of the elements on the TabPages to return their data properly before the user selects that TabPage?

    Read the article

  • asp:menu selected Menu item Highlight

    - by Naimur
    Hi, im using asp:menu for showing the menus in masterpage. If i click the menu item 1, the corresponding page is loading in the content page. I need that the selected Menu item should be highlighted by some color.pls Help me out Menu coding is follows: <items> <asp:menuitem text="Home" Value="Home" NavigateUrl="~/page1.aspx"></asp:menuitem> <asp:MenuItem NavigateUrl="~/page2.aspx" Text="About" value="About"></asp:MenuItem> <asp:MenuItem NavigateUrl="~/page1.aspx" Text="Contact" Value="Contact"></asp:MenuItem> </items> <StaticSelectedStyle BackColor="#1C5E55" /> <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" /> <DynamicHoverStyle BackColor="#666666" ForeColor="White" /> <DynamicMenuStyle BackColor="#E3EAEB" /> <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" /> <StaticHoverStyle BackColor="#666666" ForeColor="White" /> <StaticItemTemplate> <%# Eval("Text") %> </StaticItemTemplate> </asp:menu>

    Read the article

  • Strange UIKit bug, table view row stays selected

    - by Can Berk Güder
    I'm facing what appears to be a UIKit bug, and it takes the combination of two less commonly used features to reproduce it, so please bear with me here. I have quite the common view hierarchy: UITabBarController -> UINavigationController -> UITableViewController and the table view controller pushes another table view controller onto the navigation controller's stack when a row is selected. There's absolutely nothing special or fancy in the code here. However, the second UITableViewController, the "detail view controller" if you will, does two things: It sets hidesBottomBarWhenPushed to YES in its init method, so the tab bar is hidden when this controller is pushed: - (id)initWithStyle:(UITableViewStyle)style { if(self = [super initWithStyle:style]) { self.hidesBottomBarWhenPushed = YES; } return self; } It calls setToolbarHidden:NO animated:YES and setToolbarHidden:YES animated:YES on self.navigationController in viewWillAppear: and viewWillDisappear: respectively, causing the UIToolbar provided by UINavigationController to be displayed and hidden with animations: - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.navigationController setToolbarHidden:NO animated:YES]; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [self.navigationController setToolbarHidden:YES animated:YES]; } Now, if the second UITableViewController was pushed by selecting the row at the bottom of the screen (it doesn't have to be the last row) in the first controller, this row does not automatically get deselected when the user immediately or eventually returns to the first controller. Further, the row cannot be deselected by calling deselectRowAtIndexPath:animated: on self.tableView in viewWillAppear: or viewDidAppear: in the first controller. I'm guessing this is a bug in UITableViewController's drawing code which of course only draws visible rows, but unfortunately fails to determine correctly if the bottommost row will be visible in this case. I failed to find anything on this on Google or OpenRadar, and was wondering if anyone else on SO had this problem or knew a solution/workaround.

    Read the article

  • JList - deselect when clicking an already selected item

    - by Peter
    If a selected index on a JList is clicked, I want it to de-select. In other words, clicking on the indices actually toggles their selection. Didn't look like this was supported, so I tried list.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent evt) { java.awt.Point point = evt.getPoint(); int index = list.locationToIndex(point); if (list.isSelectedIndex(index)) list.removeSelectionInterval(index, index); } }); The problem here is that this is being invoked after JList has already acted on the mouse event, so it deselects everything. So then I tried removing all of JList's MouseListeners, adding my own, and then adding all of the default listeners back. That didn't work, since JList would reselect the index after I had deselected it. Anyway, what I eventually came up with is MouseListener[] mls = list.getMouseListeners(); for (MouseListener ml : mls) list.removeMouseListener(ml); list.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent evt) { java.awt.Point point = evt.getPoint(); final int index = list.locationToIndex(point); if (list.isSelectedIndex(index)) SwingUtilities.invokeLater(new Runnable() { public void run() { list.removeSelectionInterval(index, index); } }); } }); for (MouseListener ml : mls) list.addMouseListener(ml); ... and that works. But I don't like it. Is there a better way?

    Read the article

  • WPF ComboBox TemplateBinding to selected value

    - by Greg R
    I'm trying to create an editable textbox via a drop down of selected values. Basically in Red Only mode I want the drop down to be a disabled textbox. It works fine when I do this with SelectedValue but when I need it to display the dropdown text and not the value. This is what I have: <Style x:Key="EditableDropDownValueOnly" TargetType="ComboBox"> <Setter Property="Width" Value="Auto" /> <Setter Property="FontSize" Value="11" /> <Setter Property="HorizontalAlignment" Value="Left" /> <Setter Property="FontFamily" Value="Verdana" /> <Setter Property="MinWidth" Value="25" /> <Style.Triggers> <Trigger Property="IsReadOnly" Value="True"> <Setter Property="Background" Value="#FFFFFF" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ComboBox"> <TextBox Text="{TemplateBinding SelectedItem, Converter={StaticResource StringCaseConverter}}" BorderThickness="0" Background="Transparent" FontSize="{TemplateBinding FontSize}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" FontFamily="{TemplateBinding FontFamily}" Width="{TemplateBinding Width}" TextWrapping="Wrap"/> </ControlTemplate> </Setter.Value> </Setter> </Trigger> </Style.Triggers> </Style> SelectedItem is a KeyValuePair, since my drop down is bound to a dictionary. I'm trying to display the "Value" element in my template. Is that possible? Thanks a lot!

    Read the article

  • nested form collection_select new value overwriting previous selected values

    - by bharath
    Nested form <%= nested_form_for(@bill) do |f| %> <p><%= f.link_to_add "Add Product", :bill_line_items %> </p> Partial of bill line items <%= javascript_include_tag 'bill'%> <%= f.hidden_field :bill_id %> <%- prices = Hash[Product.all.map{|p| [p.id, p.price]}].to_json %> <%= f.label :product_id %> <%= f.collection_select :product_id ,Product.all,:id,:name, :class => 'product', :prompt => "Select a Product", input_html: {data: {prices: prices}}%> <br/ > <%= f.label :price, "price"%> <%= f.text_field :price, :size=>20, :class =>"price" %><br/> bill.js jQuery(document).ready(function(){ jQuery('.product').change(function() { var product_id = jQuery(this).val(); var price = eval(jQuery(this).data("prices"))[product_id]; jQuery('.price').val(price); }); }); Rails 3.2 Issue: Second click on Add Product & on selecting the product When we select the second product the price of second product is overwriting on the price of the first selected product. Request help.

    Read the article

  • Databinding combobox selected item to settings

    - by Tuukka
    I store user specified settings using application settings properties and databinding. It has been working fine, until i want user selected to font for combobox. Databinding between user settings and combobox not working. I want to store font family name. App.XML <Application.Resources> <ResourceDictionary> <properties:Settings x:Key="Settings" /> </ResourceDictionary> </Application.Resources> Window.XML <ComboBox Name="Families" ItemsSource="{x:Static Fonts.SystemFontFamilies}" <!-- This line --> SelectedItem="{Binding Source={StaticResource Settings}, Path=Default.Font, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Margin="57,122,199,118"> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding}" FontFamily="{Binding}"/> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> Settings: font String User Arial

    Read the article

  • sending a selected value from a dropdownlist to a servlet with xhr

    - by kawtousse
    I am trying to send the clicked value of a dropdown list to my servlet to run a SQL query using the value received. To do it I am using Ajax like that: function showProject(prj) { xmlhttp = GetXmlHttpObject(); if (xmlhttp == null) { alert ("Browser does not support HTTP Request"); return; } var url = "ServletxmlGenerator.java"; idprj = prj.options[prj.selectedIndex].value; url = url + "?idprj=" + idprj; xmlhttp.onreadystatechange = stateChanged; xmlhttp.open("GET",url,true); xmlhttp.send(null); } The servlet when String projectcode=(String) request.getParameter("idprj"); returns null. When I select a value from the JSP that construct the dropdown list and from which the function showProject is handled the same thing is happned. It returns always null. So the parameter(idprj) is not passed anyway. How can I handle with this. I need to send the selected value to the servlet to run my SQL query.

    Read the article

  • Measuring execution time of selected loops

    - by user95281
    I want to measure the running times of selected loops in a C program so as to see what percentage of the total time for executing the program (on linux) is spent in these loops. I should be able to specify the loops for which the performance should be measured. I have tried out several tools (vtune, hpctoolkit, oprofile) in the last few days and none of them seem to do this. They all find the performance bottlenecks and just show the time for those. Thats because these tools only store the time taken that is above a threshold (~1ms). So if one loop takes lesser time than that then its execution time won't be reported. The basic block counting feature of gprof depends on a feature in older compilers thats not supported now. I could manually write a simple timer using gettimeofday or something like that but for some cases it won't give accurate results. For ex: for (i = 0; i < 1000; ++i) { for (j = 0; j < N; ++j) { //do some work here } } Now here I want to measure the total time spent in the inner loop and I will have to put a call to gettimeofday inside the first loop. So gettimeofday itself will get called a 1000 times which introduces its own overhead and the result will be inaccurate.

    Read the article

  • UITableView not responding to row selection until a different row is selected

    - by Larry Fransson
    This is driving me nuts. I have searched on everything I can think of to find a solution but haven't found one yet. I've got a UITableView that uses custom cells. The accessory is the detail disclosure button. I would like the cell to respond to either row selection or the disclosure button being tapped. It responds to the disclosure button just as you would expect. But selecting the row is a different story. When I select the row, it highlights, but nothing happens until I tap a different row. Then the previously selected row does what it was supposed to do, which is to create and push a new view controller for that row. If I tap a single row five times and then tap a different row, it then creates and pushes five view controllers for that first row. It does this both in the simulator and on the device. What's really maddening is that I have another tableview in the same application that responds correctly to row selection or tapping the detail disclosure button. I can't find anything I've done differently between the two. Has anyone seen this before?

    Read the article

  • How save selected switch option

    - by Rkm
    System UIviewcontroller has button , Tap on button i need to fire Info Tableviewcontroller. Tableviewcontroller itself UISwitch. My question is I need to save last selected switch option ON/OFF in UISwitch how to set my control. @implementation Info // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } if (indexPath.section) { cell.textLabel.text = @"Sounds"; cell.selectionStyle = UITableViewCellSelectionStyleNone; UISwitch *switchView = [[UISwitch alloc] initWithFrame:CGRectZero]; cell.accessoryView = switchView; [switchView setOn:NO animated:NO]; [switchView addTarget:self action:@selector(switchChanged_Sounds:) forControlEvents:UIControlEventValueChanged]; [switchView release]; return cell ; } } - (void) switchChanged_Sounds:(id)sender { UISwitch* switchControl = sender; NSLog( @"The switchChanged_Sounds is %@", switchControl.on ? @"ON" : @"OFF" ); }

    Read the article

  • Set the selected item for a combobox in a datagrid

    - by JingJingTao
    I am using a datagrid which has many combobox fields in it, when I click the datagrid combobox the selected item or highlighted value is the last item in the list, but I would like it to highlight the first(top) item in the list. I know for just a combobox, all I need to do is change the combobox.selecteditem or combobox.selectedindex, but I'm not sure what to do in this case. I have binded the combobox to a table in the database and used a datatable to store the combobox values and then I add a row to the datatable, I think the reason the last item in the combobox is highlighted is because I added a row to the datatable. Thank you for your help. String strGetTypes = "SELECT holidaycodeVARCHAR4Pk, codedescVARCHAR45 FROM holidaytype ORDER BY holidaycodeVARCHAR4Pk Desc"; DataTable dtHolidayType = new DataTable(); MySqlDataAdapter dbaElements = new MySqlDataAdapter(strGetTypes, ShareSqlSettings.dbConnect); dbaElements.Fill(dtHolidayType); DataGridViewComboBoxCell cboxDays = new DataGridViewComboBoxCell(); cboxDays.DataSource = dtHolidayType; cboxDays.DisplayMember = "codedescVARCHAR45"; cboxDays.ValueMember = "holidaycodeVARCHAR4Pk"; //Blank row dtHolidayType.Rows.Add(1); // gridDailyEmp.Rows[j].Cells[day] = cboxDays;

    Read the article

  • jQuery UI Rang Slider show divs based on selected range

    - by andi_sf
    I have set up a range slider that should show/hide divs based on their range values - meaning if the range of the one specifies in the div falls into the selected range in the slider it should show - the others hide. Somehow it does not work correctly - if anybody could help that would be greatly appreciated. My code so far: $("#slider").slider({ range: true, min: 150, max: 280, step: 5, values: [150, 280], slide: function(event, ui) { $("#amount").val('Min. Value' + ui.values[0] + ' - Max. Value' + ui.values[1]); }, change: function(event, ui) { $('#col-2 div').each(function(){ var valueS = parseInt($(this).attr("class")); var valueX = parseInt($(this).attr("title")); if (valueS < ui.values[0] && valueX <= ui.values[1] || valueS ui.values[0] && valueX = ui.values[1] ) { $(this).stop().animate({opacity: 0.25}, 500) } else { $(this).stop().animate({opacity: 1.0}, 500) $("#amount").val('Min. Value' + ui.values[0] + ' - Max. Value' + ui.values[1]); } }); } }); $("#amount").val('Min. Value' + $("#slider").slider("values", 0) + ' - Max. Value' + $("#slider").slider("values", 1)); }); I have also posted a sample at: http://www.webdesigneroakland.com/slider/444range_slider.html

    Read the article

  • Hide/Show Text Field based on Selected value - ROR

    - by Tau
    I am new to ROR. I am trying to show a "Others" text field only if the selected value is "others". I am trying to make hide/show function to be as general as possible, since I will need it in many controller. If anyone can help enlightening me, I will really appreciate it. BTW, I am using Rails 2.1.1 ruby 1.8.7 general_info.html.erb <div> <%= f.label :location_id, "Location:" %> <%= f.collection_select(:location_id, Event.locations, :id, :name, {:prompt => true}, {:onchange => remote_function( :url => {:action => "showHideDOMOther"}, :with => "'selectedText='+this.options[this.selectedIndex].text + '&other_div='+'loc_other'")}) %> </div> <div id="loc_other" style="display:none"> <%= f.label :location_others, "Others:" %> <%= f.text_field :location_others %> </div> info_controller.rb def showHideDomOther render :update do |page| page.showHideDOM("Others", params[:selectedText], params[:other_div]) end end ... application_helper.rb def showHideDOM(targetString, selectedText, targetDiv) if selectedText.casecmp targetString page.hide targetDiv else page.show targetDiv end end Seem to get the correct parameters value, but nothing seems to happen. This is what I see from the console when I changed the value of selection to "Others". Parameters: {"action"=>"showHideDOMOther", "authenticity_token"=>"e7da7ce4631480b482e29da9c0fde4c026a7a70d", "other_div"=>"loc_other", "controller"=>"events", "selectedText"=>"Others"} NoMethodError (undefined method search_generic_view_paths?' for #<EventsController:0xa41c720>): /vendor/plugins/active_scaffold/lib/extensions/generic_view_paths.rb:40:infind_template_extension_from_handler' C:/usr/lib/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action_view/template_finder.rb:138:in pick_template_extension' C:/usr/lib/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action_view/template_finder.rb:115:infile_exists?' : Rendering C:/usr/lib/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/templates/rescues/layout.erb (internal_server_error)

    Read the article

  • Android How to get position of selected item from gridview without using onclicklistner, using ontouchlistner instead

    - by zonemikel
    I have a gridview, I need to do stuff on motioneven.action_down and do something for motioneven.action_up ... using onclicklistener is great but does not give me this needed functionality. Is there anyway to easily call the gridview and get its selected item in a ontouchlistener ? I've been having limited success with making my own implementation. Its hard to get the right x,y because if i call the child it gives me the x and y relative to the child so a button would be 0,0 to 48,48 but it does not tell you the actual location on the screen relative to the gridview or the screen itself. this is what i've been doing, its partially working so far. Grid.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { int x = (int)event.getX(); int y = (int)event.getY(); int position = 0; int childCount = Grid.getChildCount(); Message msg = new Message(); Rect ButtonRect = new Rect(); Grid.getChildAt(0).getDrawingRect(ButtonRect); int InitialLeft = ButtonRect.left + 10; ButtonRect.offsetTo(InitialLeft, ButtonRect.top); // while(position < childCount){ if(ButtonRect.contains(x,y)){break;} if(ButtonRect.right + ButtonRect.width() > Grid.getWidth()) { ButtonRect.offsetTo(InitialLeft, ButtonRect.bottom);} position++; ButtonRect.offsetTo(ButtonRect.right, ButtonRect.top); } msg.what = position; msg.arg1 = ButtonRect.bottom; msg.arg2 = y; cHandler.sendMessage(msg); }// end if action up if (event.getAction() == MotionEvent.ACTION_UP) { } return false; } });

    Read the article

  • Javascript: Change li class if checkbox is selected (on load)

    - by BoDiE2003
    I have this code on javascript side: function changeSelectionStyle(id) { if(document.getElementById(id).className != 'yes'){ document.getElementById(id).className = 'yes'; } else{document.getElementById(id).className = '';} } And this on html: <ul> <li id="selectedAuthorities-4_1li" class=""> <input type="checkbox" id="selectedAuthorities-4_1" name="selectedAuthorities" value="ROLE_ADD_COMMENT_TO_CV" checked="checked" onload="changeSelectionStyle(this.id + 'li');" onclick="changeSelectionStyle(this.id + 'li'); checkFatherSelection(this.id);"> <a href="#" onclick="document.getElementById('selectedAuthorities-4_1').click(); return false;"> Agregar comentario <samp><b></b>Permite agregar comentario en el detalle.</samp> </a> </li> </ul> Well what I cant get work is when the checkbox is selected, on load, the JS should check it, and assign class="yes" to the li, here: <li id="selectedAuthorities-4_1li" class=""> Any suggestions? Thank you

    Read the article

  • Display one div if nothing is selected

    - by Levani
    I use this javascript to display different div classes upon selection. I need to display one div class if nothing is selected, for example when page is loaded, and that replace it with one of the divs according to the selection... <script type="text/javascript"><!-- var lastDiv = ""; function showDiv(divName) { // hide last div if (lastDiv) { document.getElementById(lastDiv).className = "hiddenDiv"; } //if value of the box is not nothing and an object with that name exists, then change the class if (divName && document.getElementById(divName)) { document.getElementById(divName).className = "visibleDiv"; lastDiv = divName; } } //--> </script> css: <style type="text/css" media="screen"><!-- .hiddenDiv { display: none; } .visibleDiv { display: block; border: 1px grey solid; } --></style> HTML: <form id="FormName" action="blah.php" method="get" name="FormName"> <select name="selectName" size="1" onChange="showDiv(this.value);"> <option value="">Choose One...</option> <option value="one">first</option> <option value="two">second</option> <option value="three">third</option> </select> </form> <p id="one" class="hiddenDiv">This is paragraph 1.</p> <p id="two" class="hiddenDiv">This is paragraph 2.</p> <p id="three" class="hiddenDiv">This is paragraph 3.</p> Can anyone please help?

    Read the article

< Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >