Search Results

Search found 3844 results on 154 pages for 'detect'.

Page 42/154 | < Previous Page | 38 39 40 41 42 43 44 45 46 47 48 49  | Next Page >

  • How can I detect if a string contains punctuation marks at the end?

    - by Sheehan Alam
    Lets assume I have the string: "Hello I like your shoes #today...!" I am tokenizing the string by spaces: return [string componentsSeparatedByString:@" "]; So my array contains: Hello I like your shoes #today...! I want to focus on "#today...!" any word that has a # in the prefix I am changing the font color. How can I make sure that only "#today" has its font color changed? I would basically like to figure out if a word has a punctuation mark at the end, and change the color for characters before the punctuation mark.

    Read the article

  • How to detect if a certain range resides (partly) within an other range?

    - by Tom
    Lets say I've got two squares and I know their positions, a red and blue square: redTopX; redTopY; redBotX; redBotY; blueTopX; blueTopY; blueBotX; blueBotY; Now, I want to check if square blue resides (partly) within (or around) square red. This can happen in a lot of situations, as you can see in this image I created to illustrate my situation better: Note that there's always only one blue and one red square, I just added multiple so I didn't have to redraw 18 times. My original logic was simple, I'd check all corners of square blue and see if any of them are inside square red: if ( ((redTopX >= blueTopX) && (redTopY >= blueTopY) && (redTopX <= blueBotX) && (redTopY <= blueBotY)) || //top left ((redBotX >= blueTopX) && (redTopY >= blueTopY) && (redBotX <= blueBotX) && (redTopY <= blueBotY)) || //top right ((redTopX >= blueTopX) && (redBotY >= blueTopY) && (redTopX <= blueBotX) && (redBotY <= blueBotY)) || //bottom left ((redBotX >= blueTopX) && (redBotY >= blueTopY) && (redBotX <= blueBotX) && (redBotY <= blueBotY)) //bottom right ) { //blue resides in red } Unfortunately, there are a couple of flaws in this logic. For example, what if red surrounds blue (like in situation 1)? I thought this would be pretty easy but am having trouble coming up with a good way of covering all these situations.. can anyone help me out here? Regards, Tom

    Read the article

  • How to detect textarea or input type="text" editing?

    - by kavoir.com
    I use this snippet to prevent the user from accidentally navigating away from the editing page: var warning = false; window.onbeforeunload = function() { if (warning) { return ''; } } Now I want to set the variable warning to be true if any of the textarea or input type="text" has been modified, I want to use the onkeyup event such as in: document.getElementById('textarea_id').onkeyup = function() { warning = true; } But it's not working. Don't quite want to use jQuery on this. Any insights?

    Read the article

  • How to detect crashing tabed webbrowser and handle it?

    - by David Eaton
    I have a desktop application (forms) with a tab control, I assign a tab and a new custom webrowser control. I open up about 10 of these tabs. Each one visits about 100 - 500 different pages. The trouble is that if 1 webbrowser control has a problem it shuts down the entire program. I want to be able to close the offending webbrowser control and open a new one in it's place. Is there any event that I need to subscribe to catch a crashing or unresponsive webbrowser control ? I am using C# on windows 7 (Forms), .NET framework v4 =============================================================== UPDATE: 1 - The Tabbed WebBrowser Example Here is the code I have and How I use the webbrowser control in the most basic way. Create a new forms project and name it SimpleWeb Add a new class and name it myWeb.cs, here is the code to use. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; using System.Security.Policy; namespace SimpleWeb { //inhert all of webbrowser class myWeb : WebBrowser { public myWeb() { //no javascript errors this.ScriptErrorsSuppressed = true; //Something we want set? AssignEvents(); } //keep near the top private void AssignEvents() { //assign WebBrowser events to our custom methods Navigated += myWeb_Navigated; DocumentCompleted += myWeb_DocumentCompleted; Navigating += myWeb_Navigating; NewWindow += myWeb_NewWindow; } #region Events //List of events:http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser_events%28v=vs.100%29.aspx //Fired when a new windows opens private void myWeb_NewWindow(object sender, System.ComponentModel.CancelEventArgs e) { //cancel all popup windows e.Cancel = true; //beep to let you know canceled new window Console.Beep(9000, 200); } //Fired before page is navigated (not sure if its before or during?) private void myWeb_Navigating(object sender, System.Windows.Forms.WebBrowserNavigatingEventArgs args) { } //Fired after page is navigated (but not loaded) private void myWeb_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs args) { } //Fired after page is loaded (Catch 22 - Iframes could be considered a page, can fire more than once. Ads are good examples) private void myWeb_DocumentCompleted(System.Object sender, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs args) { } #endregion //Answer supplied by mo. (modified)? public void OpenUrl(string url) { try { //this.OpenUrl(url); this.Navigate(url); } catch (Exception ex) { MessageBox.Show("Your App Crashed! Because = " + ex.ToString()); //MyApplication.HandleException(ex); } } //Keep near the bottom private void RemoveEvents() { //Remove Events Navigated -= myWeb_Navigated; DocumentCompleted -= myWeb_DocumentCompleted; Navigating -= myWeb_Navigating; NewWindow -= myWeb_NewWindow; } } } On Form1 drag a standard tabControl and set the dock to fill, you can go into the tab collection and delete the pre-populated tabs if you like. Right Click on Form1 and Select "View Code" and replace it with this code. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using mshtml; namespace SimpleWeb { public partial class Form1 : Form { public Form1() { InitializeComponent(); //Load Up 10 Tabs for (int i = 0; i <= 10; i++) { newTab("Test_" + i, "http://wwww.yahoo.com"); } } private void newTab(string Title, String Url) { //Create a new Tab TabPage newTab = new TabPage(); newTab.Name = Title; newTab.Text = Title; //create webbrowser Instance myWeb newWeb = new myWeb(); //Add webbrowser to new tab newTab.Controls.Add(newWeb); newWeb.Dock = DockStyle.Fill; //Add New Tab to Tab Pages tabControl1.TabPages.Add(newTab); newWeb.OpenUrl(Url); } } } Save and Run the project. Using the answer below by mo. , you can surf the first url with no problem, but what about all the urls the user clicks on? How do we check those? I prefer not to add events to every single html element on a page, there has to be a way to run the new urls thru the function OpenUrl before it navigates without having an endless loop. Thanks.

    Read the article

  • How do I detect a Word table with (horizontally) merged cells?

    - by Reuben
    When a Word table contains horizontally merged cells, accessing aTable.Columns.First or performing a For Each over aTable.Columns will result in an error. Is there a way to determine if a table contains horizontally merged cells without resulting in an error? I've read Determine if a Word cell is merged, but that is about detecting if a particular Word table cell is merged, rather than does the whole table have any merged cells.

    Read the article

  • How to detect tap on uiview with lots of controls?

    - by kodcu
    My problem is about tap detection. I have a uiviewcontroller and there are some controls on uiview (labels, buttons, tableview, imageview, etc..) When I tap the uibutton I display a small uiview (200x150), if the user taps the uibuttons in smallview I hide the smallview. But I can't hide the uiview if the user taps the background. I tried this code.. -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ //NSLog(@"Touches began."); [self hideShareView]; } It doesn't work if I tap the another button in the uiviewcontrols view. I just want my uiviewcontrol's uiview to react first. I think its about firstResponder but I dont know how to set it first. edit: i want it to work like a uiPopover in ipad.

    Read the article

  • How to detect if collection contain instance of specific type?

    - by KentZhou
    Suppose I create collection like Collection<IMyType> coll; Then I have many implelentations of IMyTypem like, T1, T2, T3... Then I want know if the collection coll contains a instance of type T1. So I want to write a method like public bool ContainType( <T>){...} here the param should be class type, not class instance. How to write code for this kind of issue?

    Read the article

  • How do I detect a file write error in C?

    - by rich
    I have an embedded environment where a user might insert or remove a USB flash drive. I would like to know if the drive has been removed, or if there is some other problem when I try to write to the drive. However, Linux just saves the information in its buffers and returns with no indicated error. The computer I'm using comes with a 2.4.26 kernel and libc 2.3.2. I'm mounting the drive this way: i = mount(MEMORY_DEV_PATH, MEMORY_MNT_PATH, "vfat", MS_SYNCHRONOUS, NULL); That works: 50:/root # mount /dev/scsi/host0/bus0/target0/lun0/part1 on /mem type vfat (rw,sync) 50:/root # Later, I try to copy a file to it: int ifile, ofile; ifile = open("/tmp/tmpmidi.mid", O_RDONLY); if (ifile < 0) { perror("open in"); break; } ofile = open(current_file_name.c_str(), O_WRONLY | O_SYNC); if (ofile < 0) { perror("open out"); break; } #define BUFSZ 256 char buffer[BUFSZ]; while (1) { i = read(ifile, buffer, BUFSZ); if (i < 0) { perror("read"); break; } j = write(ofile, buffer, i); if (j < 0) { perror("write"); break; } if (i != j) { perror("Sizes wrong"); break; } if (i < BUFSZ) { printf("Copy is finished, I hope\n"); close(ifile); close(ofile); break; } } If this snippet of code is executed with a write-protected USB memory, the result is Copy is finished, I hope amid a flurry of error messages from the kernel on the console. I believe the same thing would happen if I simply removed the USB drive (without unmounting it). I have also fiddled with devfs. I figured out how to get it to automatically mount the drive, (with the REGISTER event) but it never seems to trigger the UNREGISTER when I pull out the memory. How can I determine in my program whether I have successfully created a file? Update 4 July: It was a silly oversight of me not to check the result from close(). Unfortunately, the file can be closed without error. So that didn't help. What about fsync()? That sounds like a good idea, but that didn't catch the error either. There might be some interesting information in /sys if I had such a thing. I believe that didn't get added until 2.6.?. The comment(s) about the quality of my flash drive are probably justified. It's one of the earlier ones. In fact, write protect switches seem to be extremely rare these days. I think I have to use the overkill option: Create a file, unmount & remount the drive, and check to see if the file is there. If that doesn't solve my problem, then something is really messed up! Note to myself: Make sure the file you try to create isn't already there! By the way, this does happen to be a C++ program. You can tell by the .c_str() which I had intended to edit out for simplicity.

    Read the article

  • How might one detect the first run of a program?

    - by Julian H. Lam
    In my web application, users can download a .tar.gz archive containing the app files. However, because the MySQL database won't have been configured then, the user needs to run the install script located in ./install. I "catch" the user upon first run of the app by checking to see if the ./install directory exists. If so, the index.php page redirects the user to the install script. However, I was wondering if there were a more elegant way to "catch" a user upon first-run of a program. Someone on IRC suggested the web-server create a file .installed upon completion, but because the web server might not have write privileges to the web root directory, I can't rely on that. How would you go about solving this problem, or is my solution workable?

    Read the article

  • How to detect the active iTunes store on the iPhone/iPod Touch/iPad?

    - by Paul
    I'd like to be able to determine which store the user connects to from inside my app, so that I can direct them to some appropriate content for their device AND store. Does anyone know how to get this information? Basically, if the user is in the UK, and connects to the UK store, I want my function/method to return GB, if in Korea, I want KR, Australia = AU etc. Any help would be appreciated.

    Read the article

  • How to detect an active x component that does not respond any more?

    - by koschi
    My application is written in C++ and uses the Qt framework. I use the QAxWidget class to access an active x component. Now I need some kind of mechanism that notifies my application each time the active x component has crashed or does not respond any more (due to dead lock or infinite loop). (1) can easily been done by watching the external process of the active x component. But maybe there is a more elegant approach? But how can (2) be implemented?

    Read the article

  • How can we detect a touch of a sprite?

    - by srikanth rongali
    I have two sprites in my app. Both should have touches enabled and both touches are independent of one another. And if I touch the screen (not on sprites) it should have different touches. My problem is all three sprite1, sprite2, remaining screen should have independent touches. But my program is taking all the touches as same. How can I make them as what I needed ? Thank You.

    Read the article

  • How to detect touch over a UIView when touched over a UIButton?

    - by jglievano
    I'm using (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event, and (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event to handle some dragging on a UIView. This UIView however have some UIButtons as subviews of the UIView and when the user touches over a UIButton (which are also over the UIView) the touches methods aren't called. I need the touch methods in the UIView to be called at all times and still have the UIButtons working, how can I achieve this?

    Read the article

  • How to detect when a long download is finished in a web server?

    - by Shabbyrobe
    I need a web server that allows me to remove a file after it has been successfully downloaded once. Is there any way to do this with apache? Is there another web server I can use for this task? I had already looked into Tornado for this purpose, but couldn't find a way to get an event to fire as soon as the download finished. the on_connection_close would only fire when I shut down the server. I'd prefer something PHP or Python-based if I have to code it myself.

    Read the article

  • Detect at runtime which country's App Store my iPhone app was downloaded from?

    - by Mike McMaster
    I have a feature in my iPhone application that, for business reasons, should only be shown/available to customers in the US. If I want to release this app to App Stores outside the US, what's the best way to figure out which country I'm in without relying on user-defined settings such as language and locale? In my mind, the ideal solution is that there's some runtime property that can tell me which App Store country the app was downloaded from, and I can take action accordingly. Looking through the docs and searching the web, I'm not coming up with anything in this department. I don't expect the solution to be 100% foolproof as far as users not being in the country they say they're from, but as close as possible would be nice. I suppose one solution would be to make a separate build for a new product on the App Store and have two versions, one for the US and one for the others, but that doesn't seem ideal. I'm hoping it can be the same product on the App Store to prevent things like fragmentation of user reviews. Thanks in advance!

    Read the article

  • Best practice to detect iPhone app only access for web services?

    - by Gaius Parx
    I am developing an iPhone app together with web services. The iPhone app will use GET or POST to retrieve data from the web services such as http://www.myserver.com/api/top10songs.json to get data for top ten songs for example. There is no user account and password for the iPhone app. What is the best practice to ensure that only my iPhone app have access to the web API http://www.myserver.com/api/top10songs.json? iPhone SDK's UIDevice uniqueueIdentifier is not sufficient as anyone can fake the device id as parameter making the API call using wget, curl or web browsers. The web services API will not be published. The data of the web services is not secret and private, I just want to prevent abuse as there are also API to write some data to the server such as usage log.

    Read the article

  • How to detect .NET WPF memory leak or GC long run?

    - by Néstor Sánchez A.
    I have the next very strange situation and problem: .NET 4.0 application for diagram editing (WPF). Runs ok in my PC: 8GM RAM, 3.0GHz, i7 quad-core. While creating objects (mostly diagram nodes and connectors, plus all the undo/redo information) the TaskManager show, as expected, some memory usage "jumps" (up and down). These mem-usage "jumps" also remains executing AFTER user interaction ended. Maybe this is the GC cleaning/regorganizing memory? To see what is going on, I've used the Ants mem profiler, but somewhat it prevents those "jumps" to happen after user interaction. PROBLEM: It Freezes/Hangs after seconds or minutes of usage in some slow/weak laptos/netbooks of my beta testers (under 2GHz of speed and under 2GB of RAM). I was thinking of a memory leak, but... EDIT: Also, there is the case that the memory usage grows and grows until collapse (only in slow machines). In a Windows XP Mode machine (VM in Win 7) with only 512MB of RAM Assigned it works fine without mem-usage "jumps" after user interaction (no GC cleaning?!). So, I really have a big trouble because I cannot reproduce the error, only see these strange behaviour (mem jumps), and the tool supposed to show me what is happening is hiding the problem (like the "observer's paradox"). Any ideas on what's happening and how to solve it?

    Read the article

< Previous Page | 38 39 40 41 42 43 44 45 46 47 48 49  | Next Page >