selector

No callback when clicking menu item

删除回忆录丶 提交于 2019-12-04 19:20:29
I'm trying to implement a simple context menu in my FinderSync extension. I built the following using some examples, and my problem is that the callback is never called when I click the menu item. Source code: ContextMenuHelper.h #import <Foundation/Foundation.h> #include "FinderSync.h" @interface ContextMenuHelper : NSObject + (NSMenu *)buildMenu; @end ContextMenuHelper.m #import "ContextMenuHelper.h" #define SharedContextMenuTarget [ContextMenuTarget sharedInstance] @interface ContextMenuTarget : NSObject + (ContextMenuTarget *) sharedInstance; @end @implementation ContextMenuTarget - (void)

Can I put logical operators in document.querySelectorAll? If so, how?

纵然是瞬间 提交于 2019-12-04 17:48:01
问题 Let's say I want to find all div elements and span inside p . Is it possible to get all what I want in a single `querySelectorAll" invocation? Conceptually it should be something like document.querySelectorAll("div | p span") (if | means or ). 回答1: Yes. You can use the same logical operators allowed in CSS: OR: chain selectors with commas document.querySelectorAll('div, p span'); // selects divs, and spans in ps AND: chain selectors without whitespace document.querySelectorAll('div.myClass');

Objective-C va_list and selectors

穿精又带淫゛_ 提交于 2019-12-04 17:46:38
Is it possible to use @selector and performSelector: (or similar) with methods using variable arguments list? I'm writing a class that can be assigned a delegate to override the default behavior. In the presence of a delegate select method calls made on an instance of that class will be forward to the same corresponding delegate method, some which use variable argument lists. So, for instance, I need to be able to create retrieve SEL reference and message the delegate object with a method such as this: - (void)logEventWithFormat:(NSString *)format, ... { va_list argList; id del = self.delegate

JQuery Lint says: “You've used the same selector more than once.” I don't think I have

核能气质少年 提交于 2019-12-04 17:36:03
Here's my problem child: jQuery(document).ready(function() { var a = jQuery('img[title*="after"]'); a.parents('dl.gallery-item').addClass('after'); a.addClass('after'); var b = jQuery('img[title*="before"]'); b.parents('dl.gallery-item').addClass('before'); b.addClass('before'); //the following gives each image a 'name' attribute based on the caption, collapsed. jQuery('img').each(function() { var f = jQuery(this).parents('dl.gallery-item').find('dd').text(); var f = f.replace(/\s/g,''); jQuery(this).attr('name', f); }); //the following takes each 'name' attribute, finds the before, and sticks

have_tag vs. have_selector

你离开我真会死。 提交于 2019-12-04 16:47:19
I've been using have_selector with RSpec (version 2.0.1) successfully. I recently found documentation on have_tag ... with_tag ... associated with RSpec 1.3.2 and would like to use it, but RSpec gives me the error: undefined method `has_tag?' for #<ActionController::TestResponse:0x105584e80> on the following lines: response.should have_tag("div.breadcrumbs select") do with_tag(:option, :value => @brands.name) with_tag(:option, :value => @marketsize.name) end I've tried the same syntax substituting "have_selector" and "with_selector for "have_tag" and "with_tag", in which case I get the error

How to use a selector to change an ImageButton image?

耗尽温柔 提交于 2019-12-04 15:42:01
How do I make an ImageButton image change its image when you press it? I hope you find this helpful. This can all be done in the XML. 1) Import your images for both pressed and unpressed states into the res/drawable- whichever folder 2) Make your selectors. Right click on a drawable folder and select New/Android xml file. Put in the name eg "ok_button_selector.xml" and choose "selector" as the root element from the menu below. You will need to create a different selector for each button on the screen. 3) In each selector file you need to define the image that will display when clicked, like

Select and highlight a single word

只愿长相守 提交于 2019-12-04 15:21:49
I'm trying to select a single word, then apply something to it. Example as below. <p>Some text here</p> Is there a way to select the word text , then apply something to it? For example .css() - I know you can select the whole text, then select word number 2, but that's not what I'm trying to do. The word could be many places. Find <p> and children, filter their contents and search for a textual nodeType: var word = 'text'; var rgx = new RegExp('\\b('+word+')\\b', 'ig'); $('p, p *').contents().filter(function() { return this.nodeType === 3; }).each(function() { $(this).replaceWith($(this).text(

Objective-C passing methods as parameters

懵懂的女人 提交于 2019-12-04 15:14:31
问题 How do you pass one method as a parameter to another method? I'm doing this across classes. Class A: + (void)theBigFunction:(?)func{ // run the func here } Class B: - (void)littleBFunction { NSLog(@"classB little function"); } // somewhere else in the class [ClassA theBigFunction:littleBFunction] Class C: - (void)littleCFunction { NSLog(@"classC little function"); } // somewhere else in the class [ClassA theBigFunction:littleCFunction] 回答1: The type you are looking for is selector ( SEL ) and

Using a NSString to set a color for a label

时光毁灭记忆、已成空白 提交于 2019-12-04 14:59:13
I want to create a method and use a string value "redColor" to set the UIColor for a label. tableColorName is the NSString "redColor" and I tried to apply a selector to create the UIColor and apply it to my textLabel. Thanks -(void) changeLabelColor { SEL labelColor = NSSelectorFromString([NSString stringWithFormat:[@"%@", tableColorName]]); UIColor *color = [[UIColor class] performSelector:labelColor]; self.textLabel.textColor = color; } Use this method -(UIColor *)giveColorfromStringColor:(NSString *)colorname { SEL labelColor = NSSelectorFromString(colorname); UIColor *color = [UIColor

Android rounded corners in ListView

与世无争的帅哥 提交于 2019-12-04 14:14:12
I have a ListView with rounded corners made using following shape as background: <?xml version="1.0" encoding="UTF-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#ffffff"/> <corners android:bottomRightRadius="13px" android:bottomLeftRadius="13px" android:topLeftRadius="13px" android:topRightRadius="13px"/> </shape> The problem lies in the selector. It's rectangle shaped, so when selecting first or last item the corners aren't rounded anymore. I've found a very nice solution in the last post at http://www.anddev.org/view