Search Results

Search found 347 results on 14 pages for 'keycode'.

Page 11/14 | < Previous Page | 7 8 9 10 11 12 13 14  | Next Page >

  • Chrome history problem

    - by Parhs
    $("#table_exams tbody tr").click(function (event) { window.location.href="#" +$(this).attr("exam_ID"); window.location.href="/medilab/prototypes/exams/edit?examId=" + $(this).attr("exam_ID") +"&referer=" + referer; row_select(this); }); $(document).keypress(function (event) { if(event.keyCode==13) $(row_selected).trigger("click"); }); I have a little problem with this only in chrome...When user goes back chrome ignores the last href hash that my script added..but when i do a doubleclick its ok... IE and Firefox work great...

    Read the article

  • Not able to capture Enter key in WinForms text box

    - by Michael Hermes
    When the user is entering a number into a text box, I would like them to be able to press Enter and simulate pressing an Update button elsewhere on the form. I have looked this up several places online, and this seems to be the code I want, but it's not working. When data has been put in the text box and Enter is pressed, all I get is a ding. What am I doing wrong? (Visual Studio 2008) private void tbxMod_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { btnMod.PerformClick(); } }

    Read the article

  • How do I respond to a specific sequence of key presses?

    - by Sergio Tapia
    The end result is very simple, I have to have something happen when a user types in the letter "n" "o" "t" "e" in that order. 'Note' is the word. I'm making a little application for a friend that will help him take notes, and I want my application to become visible when he types in "note" from anywhere on the machine. Here's what I've got so far: if (e.KeyCode == neededLetter as Keys) { neededLetter = "o"; } I initialize the neededLetter variable with "N" but I'm stuck there. Any help?

    Read the article

  • AS3 TextField - unwanted carriage return when setting value to ""

    - by jevinkones
    I have an input TextField and have a KeyboardEvent.KEY_DOWN even listener on the stage to listen for the Keyboard.ENTER event. The event listener adds the entered text to an array or whatever, and then clears the TextField. The problem is that when the Enter key event fires and the TextField value is set to "", it leaves a carriage return in the TextField and the cursor positioned on the second line. WTF? I've been coding AS2 and AS3 for a LONG time and have never ran into this before. Am I losing my mind? Please help, people! :-) Example: var myTextArray:Array = new Array(); stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); function onKeyDown(e:KeyboardEvent):void{ if(e.keyCode == Keyboard.ENTER){ if(_inputText.text != null){ myTextArray.push(_inputText.text); } _inputText.text = ""; } }

    Read the article

  • Create an autocompleter like the Facebook status update

    - by Terw
    Hello I'm trying to create a div with contenteditable like the Facebook status update. Then I mean I want to show an autocomplete box when the user have written @. How would you do that. Currently I'm just playing with keypress and check if the keycode = 64. Somehow that works, but it doesn't validate if there's a space before the alfa, or if the user has unfocused the box, then focused it again. Any ideas? Or do you know about any plugin that works something like that? Tnx

    Read the article

  • Simulate the user clicking on a link

    - by timkl
    I want a link to be clicked when a key is pressed, I cooked up this jQuery: $('form#form1').bind("keypress", function(e){ if(e.keycode == 13 || e.keyChar == 13 || e.which == 13){ $('.LoginBoxButton a').click(); } }); It doesn't work, and I've read the following explaining why: It's important to remember that click() will not trigger the default behavior on a link, even if nothing else is preventing it. So you can't use click() by itself to simulate the user clicking on a link and being taken to another url. But how DO you simulate the user clicking on a link and being taken to another url?

    Read the article

  • Actionscript 3 Navigate with Keyboard Between Labels

    - by Sbml
    Hello I need to navigate between labels with arrow keys like a power point presentation. I have an array with labels and a KeyboardEvent. My problem is, if I am in label number four for example and click in arrow click, always goes to first label. So I need help defining my current label to go to the next on key press. My code: import flash.events.KeyboardEvent; var myLabels:Array = [ "label_1", "label_2", "label_3", "label_4"]; var nextLabel:String; var inc:int = 0; stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed); function keyPressed(evt:KeyboardEvent):void { switch(evt.keyCode) { case Keyboard.RIGHT : nextLabel = String(myLabels[inc]); gotoAndStop(nextLabel); inc++; break; } } Thanks

    Read the article

  • jQuery Event Keypress: Which key was pressed?

    - by BlaM
    With jQuery, how do I find out which key was pressed when I bind to the keypress event? $('#searchbox input').bind('keypress', function(e) {}); I want to trigger an submit when ENTER is pressed. [Update] Even though I found the (or better: one) answer myself, there seems to be some room for variation ;) Is there a difference between keyCode and which - especially if I'm just looking for ENTER, which will never be a unicode key? Do some browsers provide one property and others provide the other one?

    Read the article

  • jquery button click not firing asp.net button

    - by lloydphillips
    I've got a .net button that has an href attribute value set to 'javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$cp1$ucInvoiceSearch$btnSearch", "", true, "", "", false, true))'. I've got a textbox that when I press enter I want it to fire this event. Doing the 'Enter' event isn't an issue but I can't get the event on the href to fire using .click(). Here's my function so far: $("[id*='tbInvNo']").keyup(function(event){ var $btn = $(".pnl-invoice-search"); if(event.keyCode == 13) $btn.click(); }); I've got no idea how to get this to fire. Hope someone can help - jQuery and asp.net are driving me up the wall today! :(

    Read the article

  • Encoding a string as an integer .NET

    - by Paul Knopf
    I have a string that I would like represented uniquely as an integer. For example: A3FJEI = 34950140 How would I go about writing a EncodeAsInteger(string) method. I understand that the amount of characters in the string will make the integer increase greatly, forcing the value to become a long, not an int. Since I need the value to be an integer, I don't need the numerical representation to be entirely unique to the string. Maybe I can foreach through all the characters of the string and sum the numerical keycode of the character.

    Read the article

  • Javascript (JQuery) keyboard hijack problem

    - by user266564
    I'm making a typing tutor program using javascript. Everything is going well except that if activates browser hotkeys which disrupts the functionality of the program. When I press the single quote in Firefox it triggers "Quick find (links only)" short cut and in all browsers when I press space the page scrolls down a page. Everything is working fine outside of this. Here's the code in the head: <script type="text/javascript"> $(document).ready(function() { executeType(); }); </script> And the code I am using to capture the keyboard (simplified, but tested): function executeType() { $(document).keydown(function(event) { alert(event.keyCode); }); }

    Read the article

  • Define cursor on element

    - by sanceray3
    Hi all, I try to explain my problem. I have a <div contenteditable="true" id="my_editeur>, where I have defined a keypress “event” which allow me to add a ‘p’ when the user clicks on “enter”. It functions well, but I would like define the cursor on this new ‘p’ element, because currently my cursor stays on the first 'p' element. I have tried to use jquery focus function but it seems that we can’t use this function for ‘p’ elements. Do you know how I can do to solve my problem? Thanks very much for your help. My code : $('#my_editeur').keypress(function(e){ if(e.keyCode == 13) { e.preventDefault(); $(this).append('<p ><br /></p>'); } });

    Read the article

  • Send keystrokes to TextBox

    - by tanascius
    I have a derived TextBox where I intercept the userinput to manipulate it. However I have to preserve the original typed input. So my idea was to hold an inner TextBox within my derived class and send the user's input to that TextBox before manipulating it. The reason for this approach is that I do not want to take care of all this special actions like: typing something, ctrl+a, [del], type something else, [backspace] and so on ... However I do not know how to send a single keystroke (keycode, ascii, char) to a TextBox. Maybe you have another idea without an inner TextBox at all? Thank you!

    Read the article

  • plugin instancing

    - by Hailwood
    Hi guys, I am making a jquery tagging plugin. I have an issue that, When there is multiple instances of the plugin on the page, if you click on any <ul> that the plugin has been called on it will put focus on the <input /> in the last <ul> that the plugin has been called on. Why is this any how can I fix it. $.widget("ui.tagit", { // default options options: { tagSource: [], triggerKeys: ['enter', 'space', 'comma', 'tab'], initialTags: [], minLength: 1 }, //private variables _vars: { lastKey: null, element: null, input: null, tags: [] }, _keys: { backspace: 8, enter: 13, space: 32, comma: 44, tab: 9 }, //initialization function _create: function() { var instance = this; //store reference to the ul this._vars.element = this.element; //add class "tagit" for theming this._vars.element.addClass("tagit"); //add any initial tags added through html to the array this._vars.element.children('li').each(function() { instance.options.initialTags.push($(this).text()); }); //add the html input this._vars.element.html('<li class="tagit-new"><input class="tagit-input" type="text" /></li>'); this._vars.input = this._vars.element.find(".tagit-input"); //setup click handler $(this._vars.element).click(function(e) { if (e.target.tagName == 'A') { // Removes a tag when the little 'x' is clicked. $(e.target).parent().remove(); instance._popTag(); } else { instance._vars.input.focus(); } }); //setup autcomplete handler this.options.appendTo = this._vars.element; this.options.source = this.options.tagSource; this.options.select = function(event, ui) { instance._addTag(ui.item.value); return false; } this._vars.input.autocomplete(this.options); //setup keydown handler this._vars.input.keydown(function(e) { var lastLi = instance._vars.element.children(".tagit-choice:last"); if (e.which == instance._keys.backspace) return instance._backspace(lastLi); if (instance._isInitKey(e.which)) { event.preventDefault(); if ($(this).val().length >= instance.options.minLength) instance._addTag($(this).val()); } if (lastLi.hasClass('selected')) lastLi.removeClass('selected'); instance._vars.lastKey = e.which; }); //setup blur handler this._vars.input.blur(function() { instance._addTag($(this).val()); $(this).val(''); }); //define missing trim function for strings String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ""); }; this._initialTags(); }, _popTag: function() { return this._vars.tags.pop(); } , _addTag: function(value) { this._vars.input.val(""); value = value.replace(/,+$/, ""); value = value.trim(); if (value == "" || this._exists(value)) return false; var tag = ""; tag = '<li class="tagit-choice">' + value + '<a class="tagit-close">x</a></li>'; $(tag).insertBefore(this._vars.input.parent()); this._vars.input.val(""); this._vars.tags.push(value); } , _exists: function(value) { if (this._vars.tags.length == 0 || $.inArray(value, this._vars.tags) == -1) return false; return true; } , _isInitKey : function(keyCode) { var keyName = ""; for (var key in this._keys) if (this._keys[key] == keyCode) keyName = key if ($.inArray(keyName, this.options.triggerKeys) != -1) return true; return false; } , _backspace: function(li) { if (this._vars.input.val() == "") { // When backspace is pressed, the last tag is deleted. if (this._vars.lastKey == this._keys.backspace) { this._popTag(); li.remove(); this._vars.lastKey = null; } else { li.addClass('selected'); this._vars.lastKey = this._keys.backspace; } } return true; } , _initialTags: function() { if (this.options.initialTags.length != 0) { for (var i in this.options.initialTags) if (!this._exists(this.options.initialTags[i])) this._addTag(this.options.initialTags[i]); } } , tags: function() { return this._vars.tags; } , destroy: function() { $.Widget.prototype.destroy.apply(this, arguments); // default destroy this._vars['tags'] = []; } }) ;

    Read the article

  • How to get characters read from the keyboard?

    - by Sandy
    Hi, I am trying to get the characters read from the keyboard. I have the following list of that I wish to recognize if entered by a user. List of keyboard entries: letters [ ] ~ ^ numbers Part of the code: void HookManager_KeyUp(object sender, KeyEventArgs e) { string test = e.KeyCode.ToString(); Here numbers, letters and square brackets work correctly but the ~ and ^ which require shift key is read incorrectly. For eg. it reads ^ which is on key 6 as a value of 6 and not ^ as it should be. Any help would be appreciated. Thanks AA

    Read the article

  • Firebug profiling issue: "no activity to profile"

    - by thermal7
    I want to try some different options with some javascript (jQuery) to see which is the fastest, however I can't get profiling working properly. Here is the code I want to test. $this.keypress(function(e) { console.profile("test"); //retrieve the charcode if possible, otherwise get the keycode k = e.which ? e.which : e.CharCode; if (blockKeyCodes.indexOf("|" + k + "|") != -1 || e.ctrlKey && k == 86) e.preventDefault(); console.profileEnd(); }); However, when I run this the console states "no activity to profile". If I use console.time the result is 0ms. Anyone know how to fix this?

    Read the article

  • KeyDown event is not firing second time.

    - by stackuser1
    In my masterpage, i'm having one textbox for searching purpose. if we press enterkey it is redirecting to some otherpage. But it is happening only one time. next time when i enter some text and press enter key, it is not going to the Keydown event handler. Code: javascript Code: function SearchQuestionsAndDisplay(txt, event) { if (event.keyCode == 13) { document.location = "BrowserAddOn.aspx?SearchString=" + escape(txt.value); } return false; } Text Box: onkeyup = "return SearchQuestionsAndDisplay(this,event)" CssClass="searchtxtbox" / Please suggest me what i need to do. pl let me know if there is anything missing in my code.

    Read the article

  • Capture KeyUp event on form when child control has focus

    - by Jon B
    I need to capture the KeyUp event in my form (to toggle a "full screen mode"). Here's what I'm doing: protected override void OnKeyUp(KeyEventArgs e) { base.OnKeyUp(e); if (e.KeyCode == Keys.F12) this.ToggleFullScreen(); } private void ToggleFullScreen() { // Snazzy code goes here } This works fine, unless a control on the form has focus. In that case, I don't get the event at all (also tried OnKeyDown - no luck there either). I could handle the KeyUp event from the child control, but the controls on the form are generated dynamically, and there may be many of them - each having many children of their own. Is there any way to do this without generating event handlers for every control on the screen (which I certainly could do with a recursive function)?

    Read the article

  • Javascript height statement

    - by Sean
    This is not working and I can't figure out where I went wrong: <style> * { margin: 0px } div { height: 250px; width: 630px; overflow: hidden; vertical-align: top; position: relative; } iframe { position: absolute; left: -50px; top: -130px; } </style> <script> window.onload = function() { document.getElementsByTagName('body')[0].onkeyup = function(e) { var div = document.getElementById('capture'); if(e.keyCode == 70) { if(div.style.height == 250){ alert("Yes"); } else {alert("no");} } } }; </script>

    Read the article

  • VB.net Enter Key

    - by Andrew
    I was given the following pseudo code in order to get the form that has focus and only allow the form I want to be submitted: <script> var currentForm = document.forms[0];</script> <form ...><input onfocus="currentForm = this.form;"/></form> <form ...><input onfocus="currentForm = this.form;"/></form> function globalKeyPressed(event) { if (event.keyCode == ENTER) { // This is pseudo-code, check how to really do it currentForm.submit(); } } How would I do this for VB.net because VB.net doesn't accept System.Windows.Forms.KeyPressEventArgs. I also wanted to add that I can't have multiple forms on my website as it disrupts the loginview. So my 2 seperate 'forms' are really just a loginview and then an asp:textbox and asp:button by themselves without a form.

    Read the article

  • In FLEX, How can you stop ENTER Key from my Alert being caught by the control that initiated the Al

    - by WeeJavaDude
    I am having an issue where I show an AlertBox message when the user hits ENTER and the focus is in a text area. The pop up works fine, but when the user hits enter the Alert closes as expected, but the TextArea listener receives the ENTER event from the Alert and pops the dialog up again. I have tried a number of ways to catch and eat the event but so far I have not been lucky. Is there way to accomplish this? public function init():void { myTextInput.addEventListener(KeyboardEvent.KEY_UP, handleKeyStrokes); } public function handleKeyStrokes(evt:KeyboardEvent):void { if(evt.keyCode == Keyboard.ENTER) { myAlert = Alert.show("This is a test and only a test", "Title", 4, null, alertCallBack); } } <mx:TextInput id="myTextInput" left="600" top="10"> </mx:TextInput>

    Read the article

  • switching default keyevents actions after key combinations

    - by liysd
    I need to change default actions of two events. When I press "enter" one action occurs, when I press "shift-enter" another. I need to switch it. I means if I press "enter" than "shift-enter" action occurs. I tried something like this but if doesn't work. f(evt.keyCode == 13) { if(!evt.shiftKey){ evt.preventDefault(); evt.shiftKey = true; var e = jQuery.Event("keydown"); e.which = 13; e.shiftKey = true; $(wym._doc).trigger(e); Is there any way to do it?

    Read the article

  • ASP.NET: How to specify which button should defaultly react for an Enter press?

    - by agnieszka
    I have a webpage where there are two buttons and a textbox. When the page loads and user presses enter, the first button is clicked - and that is ok. I would like to assure that if user enters the textBox and types anything there and THEN presses enter, the second button is clicked. When I enter the textBox I can tell that the first button will be used when I press enter, because it is a bit dark-blue-bordered then. I tried javascript's if (event && event.keyCode == 13) document.getElementById("Button2").click(); but it somehow doesn't work. So my second thought was that there must be a possibility to tell the browser which button should defaultly react for an enter press when I'm in a specific textBox (the dark-blue-bordered button). Edit: it might matter that first button is input and the second one is asp:Button

    Read the article

  • Android Expandable List View Update

    - by Gaurav Arora
    I am implementing a chatting application, where I have made a service to listen all the presence changed. On the change of the presence I want to update the data and I am unable to update the data that is showing in the expandable list view. Please suggest me a means to do the same. public class UserMenuActivity extends ExpandableListActivity { private XMPPConnection connection; String name,availability,subscriptionStatus; TextView tv_Status; /** Variable Define here */ private String[] data = { "View my profile", "New Multiperson Chat", "New Broad Cast Message", "New Contact Category", "New Group", "Invite to CCM", "Search", "Expand All", "Settings", "Help", "Close" }; private String[] data_Contact = { "Rename Category","Move Contact to Category", "View my profile", "New Multiperson Chat", "New Broad Cast Message", "New Contact Category", "New Group", "Invite to CCM", "Search", "Expand All", "Settings", "Help", "Close" }; private String[] data_child_contact = { "Open chat", "Delete Contact","View my profile", "New Multiperson Chat", "New Broad Cast Message", "New Contact Category", "New Group", "Invite to CCM", "Search", "Expand All", "Settings", "Help", "Close" }; private String[] menuItem = { "Chats", "Contacts", "CGM Groups", "Pending","Request" }; private List<String> menuItemList = Arrays.asList(menuItem); private int commonGroupPosition = 0; private String etAlertVal; private DatabaseHelper dbHelper; private int categoryID, listPos; /** New Code here.. */ private ArrayList<String> groupNames; private ArrayList<ArrayList<ChildItems>> childs; private UserMenuAdapter adapter; private Object object; private String[] data2 = { "PIN Michelle", "IP Call" }; private ListView mlist2; private ImageButton mimBtnMenu; private LinearLayout mllpopmenu; private View popupView; private PopupWindow popupWindow; private AlertDialog.Builder alert; private EditText input; private TextView mtvUserName, mtvUserTagLine; private ExpandableListView mExpandableListView; public static List<CategoryDataClass> categoryList; private boolean menuType = false; private String childValContact=""; public static Context context; @Override public void onBackPressed() { if (mllpopmenu.getVisibility() == View.VISIBLE) { mllpopmenu.setVisibility(View.INVISIBLE); } else { if (CCMStaticVariable.CommonConnection.isConnected()) { CCMStaticVariable.CommonConnection.disconnect(); } super.onBackPressed(); } } @SuppressWarnings("unchecked") @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_MENU) { if (mllpopmenu.getVisibility() == View.VISIBLE) { mllpopmenu.setVisibility(View.INVISIBLE); } else { if (commonGroupPosition >= 4 && menuType == true) { if(childValContact == ""){ mllpopmenu.setVisibility(View.VISIBLE); mlist2.setAdapter(new ArrayAdapter(UserMenuActivity.this, R.layout.listviewtext, R.id.tvMenuText, data_Contact)); }else{ mllpopmenu.setVisibility(View.VISIBLE); mlist2.setAdapter(new ArrayAdapter(UserMenuActivity.this, R.layout.listviewtext, R.id.tvMenuText, data_child_contact)); } } else if (commonGroupPosition == 0) { mllpopmenu.setVisibility(View.VISIBLE); mlist2.setAdapter(new ArrayAdapter(UserMenuActivity.this, R.layout.listviewtext, R.id.tvMenuText, data)); } } return true; } return super.onKeyDown(keyCode, event); } @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.usermenulayout); dbHelper = new DatabaseHelper(UserMenuActivity.this); //this.context = context.getApplicationContext(); XMPPConn.getContactList(); connection = CCMStaticVariable.CommonConnection; Presence userPresence = new Presence(Presence.Type.available); userPresence.setPriority(24); userPresence.setMode(Presence.Mode.away); connection.sendPacket(userPresence); } @Override protected void onResume() { super.onResume(); Presence userPresence = new Presence(Presence.Type.available); userPresence.setPriority(24); userPresence.setMode(Presence.Mode.away); connection.sendPacket(userPresence); XMPPConn.getContactList(); setExpandableListView(); } public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { if (groupPosition == 1 && childPosition == 0) { startActivity(new Intent(UserMenuActivity.this, InvitetoCCMActivity.class)); } else if (groupPosition == 1 && childPosition != 0) { Intent intent = new Intent(UserMenuActivity.this, UserChatActivity.class); intent.putExtra("userNameVal", XMPPConn.mfriendList.get(childPosition - 1).friendName); startActivity(intent); } else if (groupPosition == 2 && childPosition == 0) { startActivity(new Intent(UserMenuActivity.this, CreateGroupActivity.class)); } else if (groupPosition == 2 && childPosition != 0) { String GROUP_NAME = childs.get(groupPosition).get(childPosition) .getName().toString(); int end = GROUP_NAME.indexOf("("); CCMStaticVariable.groupName = GROUP_NAME.substring(0, end).trim(); startActivity(new Intent(UserMenuActivity.this, GroupsActivity.class)); } else if (groupPosition >= 4) { childValContact = childs.get(groupPosition).get(childPosition).getName().trim(); showToast("user==>"+childValContact, 0); } return false; } private void setExpandableListView() { /***###############GROUP ARRAY ############################*/ final ArrayList<String> groupNames = new ArrayList<String>(); groupNames.add("Chats (2)"); groupNames.add("Contacts (" + XMPPConn.mfriendList.size() + ")"); groupNames.add("CGM Groups (" + XMPPConn.mGroupList.size() + ")"); groupNames.add("Pending (1)"); XMPPConn.getGroup(); categoryList = dbHelper.getAllCategory(); /**Group From Sever*/ if (XMPPConn.mGroupList.size() > 0) { for (int g = 0; g < XMPPConn.mGroupList.size(); g++) { XMPPConn.getGroupContact(XMPPConn.mGroupList.get(g).groupName); groupNames.add(XMPPConn.mGroupList.get(g).groupName + "(" + XMPPConn.mGroupContactList.size()+ ")"); } } if(categoryList.size() > 0){ for (int cat = 0; cat < categoryList.size(); cat++) { groupNames.add(categoryList.get(cat).getCategoryName()+ "(0)"); } } this.groupNames = groupNames; /*** ###########CHILD ARRAY * #################*/ ArrayList<ArrayList<ChildItems>> childs = new ArrayList<ArrayList<ChildItems>>(); ArrayList<ChildItems> child = new ArrayList<ChildItems>(); child.add(new ChildItems("Alisha", "Hi",0)); child.add(new ChildItems("Michelle", "Good Morning",0)); childs.add(child); child = new ArrayList<ChildItems>(); child.add(new ChildItems("", "",0)); if (XMPPConn.mfriendList.size() > 0) { for (int n = 0; n < XMPPConn.mfriendList.size(); n++) { child.add(new ChildItems(XMPPConn.mfriendList.get(n).friendNickName, XMPPConn.mfriendList.get(n).friendStatus, XMPPConn.mfriendList.get(n).friendState)); } } childs.add(child); /************** CGM Group Child here *********************/ child = new ArrayList<ChildItems>(); child.add(new ChildItems("", "",0)); if (XMPPConn.mGroupList.size() > 0) { for (int grop = 0; grop < XMPPConn.mGroupList.size(); grop++) { child.add(new ChildItems( XMPPConn.mGroupList.get(grop).groupName + " (" + XMPPConn.mGroupList.get(grop).groupUserCount + ")", "",0)); } } childs.add(child); child = new ArrayList<ChildItems>(); child.add(new ChildItems("Shuchi", "Pending (Waiting for Authorization)",0)); childs.add(child); /************************ Group Contact List *************************/ if (XMPPConn.mGroupList.size() > 0) { for (int g = 0; g < XMPPConn.mGroupList.size(); g++) { /** Contact List */ XMPPConn.getGroupContact(XMPPConn.mGroupList.get(g).groupName); child = new ArrayList<ChildItems>(); for (int con = 0; con < XMPPConn.mGroupContactList.size(); con++) { child.add(new ChildItems( XMPPConn.mGroupContactList.get(con).friendName, XMPPConn.mGroupContactList.get(con).friendStatus,0)); } childs.add(child); } } if(categoryList.size() > 0){ for (int cat = 0; cat < categoryList.size(); cat++) { child = new ArrayList<ChildItems>(); child.add(new ChildItems("-none-", "",0)); childs.add(child); } } this.childs = childs; /** Set Adapter here */ adapter = new UserMenuAdapter(this, groupNames, childs); setListAdapter(adapter); object = this; mlist2 = (ListView) findViewById(R.id.list2); mimBtnMenu = (ImageButton) findViewById(R.id.imBtnMenu); mllpopmenu = (LinearLayout) findViewById(R.id.llpopmenu); mtvUserName = (TextView) findViewById(R.id.tvUserName); mtvUserTagLine = (TextView) findViewById(R.id.tvUserTagLine); //Set User name.. System.out.println("CCMStaticVariable.loginUserName===" + CCMStaticVariable.loginUserName); if (!CCMStaticVariable.loginUserName.equalsIgnoreCase("")) { mtvUserName.setText("" + CCMStaticVariable.loginUserName); } /** Expandable List set here.. */ mExpandableListView = (ExpandableListView) this .findViewById(android.R.id.list); mExpandableListView.setOnGroupClickListener(new OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { XMPPConn.getContactList(); if (parent.isGroupExpanded(groupPosition)) { commonGroupPosition = 0; }else{ commonGroupPosition = groupPosition; } String GROUP_NAME = groupNames.get(groupPosition); int end = groupNames.get(groupPosition).indexOf("("); String GROUP_NAME_VALUE = GROUP_NAME.substring(0, end).trim(); if (menuItemList.contains(GROUP_NAME_VALUE)) { menuType = false; CCMStaticVariable.groupCatName = GROUP_NAME_VALUE; } else { menuType = true; CCMStaticVariable.groupCatName = GROUP_NAME_VALUE; } long findCatId = dbHelper.getCategoryID(GROUP_NAME_VALUE); if (findCatId != 0) { categoryID = (int) findCatId; } childValContact=""; showToast("Clicked on==" + GROUP_NAME_VALUE, 0); return false; } }); /** Click on item */ mlist2.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int pos,long arg3) { if (commonGroupPosition >= 4) { if(childValContact == ""){ if (pos == 0) { showAlertEdit(CCMStaticVariable.groupCatName); } /** Move contact to catgory */ if (pos == 1) { startActivity(new Intent(UserMenuActivity.this,AddContactCategoryActivity.class)); } }else{ if(pos == 0){ Intent intent = new Intent(UserMenuActivity.this,UserChatActivity.class); intent.putExtra("userNameVal",childValContact); startActivity(intent); } if(pos == 1){ XMPPConn.removeEntry(childValContact); showToast("Contact deleted sucessfully", 0); Intent intent = new Intent(UserMenuActivity.this,UserMenuActivity.class); } } } else { /** MyProfile */ if (pos == 0) { startActivity(new Intent(UserMenuActivity.this, MyProfileActivity.class)); } /** New multiperson chat start */ if (pos == 1) { startActivity(new Intent(UserMenuActivity.this, NewMultipersonChatActivity.class)); } /** New Broadcast message */ if (pos == 2) { startActivity(new Intent(UserMenuActivity.this, NewBroadcastMessageActivity.class)); } /** Click on add category */ if (pos == 3) { showAlertAdd(); } if (pos == 4) { startActivity(new Intent(UserMenuActivity.this, CreateGroupActivity.class)); } if (pos == 5) { startActivity(new Intent(UserMenuActivity.this, InvitetoCCMActivity.class)); } if (pos == 6) { startActivity(new Intent(UserMenuActivity.this, SearchActivity.class)); } if (pos == 7) { onGroupExpand(2); for (int i = 0; i < groupNames.size(); i++) { mExpandableListView.expandGroup(i); } } /** Click on settings */ if (pos == 8) { startActivity(new Intent(UserMenuActivity.this, SettingsActivity.class)); } if (pos == 10) { System.exit(0); } if (pos == 14) { if (mllpopmenu.getVisibility() == View.VISIBLE) { mllpopmenu.setVisibility(View.INVISIBLE); if (popupWindow.isShowing()) { popupWindow.dismiss(); } } else { mllpopmenu.setVisibility(View.VISIBLE); mlist2.setAdapter(new ArrayAdapter( UserMenuActivity.this, R.layout.listviewtext, R.id.tvMenuText, data)); } } } } }); } /** Toast message display here.. */ private void showToast(String msg, int time) { Toast.makeText(this, msg, time).show(); } public String showSubscriptionStatus(String friend){ return friend; } } Service.class public class UpdaterService extends Service { private XMPPConnection connection; String Friend; String user = ""; @Override public IBinder onBind(Intent arg0) { // TODO Auto-generated method stub return null; } @Override public void onCreate() { // Toast.makeText(this, "My Service Created", Toast.LENGTH_LONG).show(); super.onCreate(); } @Override public void onDestroy() { // TODO Auto-generated method stub super.onDestroy(); } @Override public void onStart(Intent intent, int startId) { // TODO Auto-generated method stub showToast("My Service Started", 0); connection = getConnection(); if (connection.isConnected()) { final Roster roster = connection.getRoster(); RosterListener r1 = new RosterListener() { @Override public void presenceChanged(Presence presence) { // TODO Auto-generated method stub XMPPConn.getContactList(); } @Override public void entriesUpdated(Collection<String> arg0) { // TODO Auto-generated method stub //notification("entriesUpdated"); } @Override public void entriesDeleted(Collection<String> arg0) { // TODO Auto-generated method stub //notification("entriesDeleted"); } @Override public void entriesAdded(Collection<String> arg0) { // TODO Auto-generated method stub Iterator<String> it = arg0.iterator(); if (it.hasNext()) { user = it.next(); } RosterEntry entry = roster.getEntry(user); if(entry.getType().toString().equalsIgnoreCase("to")){ int index_of_Alpha = Friend.indexOf("@"); String subID = Friend.substring(0, index_of_Alpha); notification("Hi "+subID+" wants to add you"); } } }; if (roster != null) { roster.setSubscriptionMode(Roster.SubscriptionMode.manual); System.out.println("subscription going on"); roster.addRosterListener(r1); } } else { showToast("Connection lost-", 0); } } protected void showToast(String msg, int time) { Toast.makeText(this, msg, time).show(); } private XMPPConnection getConnection() { return CCMStaticVariable.CommonConnection; } /** Notification manager */ private void notification(CharSequence message) { String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); int icon = R.drawable.ic_launcher; CharSequence tickerText = message; long when = System.currentTimeMillis(); Notification notification = new Notification(icon, tickerText, when); Context context = getApplicationContext(); CharSequence contentTitle = "CCM"; CharSequence contentText = message; Intent notificationIntent = new Intent(this, ManageNotification.class); notificationIntent.putExtra("Subscriber_ID",user ); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); notification.flags |= Notification.FLAG_AUTO_CANCEL; final int HELLO_ID = 1; mNotificationManager.notify(HELLO_ID, notification); } } Here is my adapter class public class UserMenuAdapter extends BaseExpandableListAdapter { private ArrayList<String> groups; private ArrayList<ArrayList<ChildItems>> childs; private Context context; public LayoutInflater inflater; ImageView img_availabiliy; private static final int[] EMPTY_STATE_SET = {}; private static final int[] GROUP_EXPANDED_STATE_SET = {android.R.attr.state_expanded}; private static final int[][] GROUP_STATE_SETS = { EMPTY_STATE_SET, // 0 GROUP_EXPANDED_STATE_SET // 1 }; public UserMenuAdapter(Context context, ArrayList<String> groups, ArrayList<ArrayList<ChildItems>> childs) { this.context = context; this.groups = groups; this.childs = childs; inflater = LayoutInflater.from(context); } @Override public Object getChild(int groupPosition, int childPosition) { return childs.get(groupPosition).get(childPosition); } @Override public long getChildId(int groupPosition, int childPosition) { return (long) (groupPosition * 1024 + childPosition); } @Override public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { View v = null; if (convertView != null) v = convertView; else v = inflater.inflate(R.layout.child_layout, parent, false); ChildItems ci = (ChildItems) getChild(groupPosition, childPosition); TextView tv = (TextView) v.findViewById(R.id.tvChild); tv.setText(ci.getName()); TextView tv2 = (TextView) v.findViewById(R.id.tvChild2); tv2.setText(ci.getDailyStatus()); img_availabiliy = (ImageView)v.findViewById(R.id.img_childlayout_AVAILABILITY); ImageView friendPics = (ImageView)v.findViewById(R.id.ivFriendPics); if(ci.getStatusState() == 1){ img_availabiliy.setImageResource(R.drawable.online); } else if(ci.getStatusState()==0){ img_availabiliy.setImageResource(R.drawable.offline); } else if (ci.getStatusState()==2) { img_availabiliy.setImageResource(R.drawable.away); } else if(ci.getStatusState()==3){ img_availabiliy.setImageResource(R.drawable.busy); } else{ img_availabiliy.setImageDrawable(null); } if((groupPosition == 1 && childPosition == 0)){ friendPics.setImageResource(R.drawable.inviteto_ccm); img_availabiliy.setVisibility(View.INVISIBLE); } else if(groupPosition == 2 && childPosition == 0){ friendPics.setImageResource(R.drawable.new_ccmgroup); img_availabiliy.setVisibility(View.VISIBLE); }else{ if(ci.getPicture()!= null){ Bitmap bitmap = BitmapFactory.decodeByteArray(ci.getPicture(), 0, ci.getPicture().length); bitmap = Bitmap.createScaledBitmap(bitmap, 50, 50, true); friendPics.setImageBitmap(bitmap); }else{ friendPics.setImageResource(R.drawable.avatar); } img_availabiliy.setVisibility(View.VISIBLE); } return v; } @Override public int getChildrenCount(int groupPosition) { return childs.get(groupPosition).size(); } @Override public Object getGroup(int groupPosition) { return groups.get(groupPosition); } @Override public int getGroupCount() { return groups.size(); } @Override public long getGroupId(int groupPosition) { return (long) (groupPosition * 1024); } @Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { View v = null; if (convertView != null) v = convertView; else v = inflater.inflate(R.layout.group_layout, parent, false); String gt = (String) getGroup(groupPosition); TextView tv2 = (TextView) v.findViewById(R.id.tvGroup); if (gt != null) tv2.setText(gt); /**Set Image on group layout, Max/min*/ View ind = v.findViewById( R.id.explist_indicator); View groupInd = v.findViewById( R.id.llgroup); if( ind != null ) { ImageView indicator = (ImageView)ind; if( getChildrenCount( groupPosition ) == 0 ) { indicator.setVisibility( View.INVISIBLE ); } else { indicator.setVisibility( View.VISIBLE ); int stateSetIndex = ( isExpanded ? 1 : 0) ; Drawable drawable = indicator.getDrawable(); drawable.setState(GROUP_STATE_SETS[stateSetIndex]); } } if( groupInd != null ) { RelativeLayout indicator2 = (RelativeLayout)groupInd; if( getChildrenCount( groupPosition ) == 0 ) { indicator2.setVisibility( View.INVISIBLE ); } else { indicator2.setVisibility( View.VISIBLE ); int stateSetIndex = ( isExpanded ? 1 : 0) ; Drawable drawable2 = indicator2.getBackground(); drawable2.setState(GROUP_STATE_SETS[stateSetIndex]); } } return v; } @Override public boolean hasStableIds() { return true; } @Override public boolean isChildSelectable(int groupPosition, int childPosition) { return true; } public void onGroupCollapsed(int groupPosition) { } public void onGroupExpanded(int groupPosition) { } } I just want to update my list in ON PRESENCE CHANGED method in the Service class.. Please suggest me a means to do the same.

    Read the article

  • I need to add a KeyboardEvent to a movie clip in Flash cs4 AS 3.0

    - by psy-sci
    I have a movieclip called keyCButton that I want to add a keyboardEvent ("C" Key) to. This will play an animation from frames 2-30 with a sound. I have watched a few tutorials but still haven't gotten the correct information to make it work. The following is my code. stage.addEventListener(KeyboardEvent.KEY_DOWN, cNote); function cNote(event:KeyboardEvent):void { if (event.keyCode == Keyboard.SPACE) { keyCButton.gotoAndPlay(2) } } at frame 30 the code tells it to stop and then go back to frame 1 This works for the MouseEvent.CLICK but the KeyboardEvent does nothing.

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14  | Next Page >