2012-06-21 8 views
7

व्यू-आधारित एनएसटीबल व्यू में केवल मानक व्यवहार होता है, जहां तालिका के अंदर एक टेक्स्ट फ़ील्ड बनाने के लिए पहले उत्तरदाता को उपयोगकर्ता को डबल क्लिक करना होगा या एकल क्लिक करना होगा और "शांत रहना होगा"।एक दृश्य-आधारित एनएसटीबल व्यू में, एक क्लिक के साथ पहले उत्तरदाता को कैसे नियंत्रित करते हैं?

हालांकि, लचीलापन दृश्य-आधारित एनएसटीबल व्यू ऑफ़र दिया गया है, लेकिन यह व्यवहार हमेशा वांछनीय नहीं है क्योंकि अब "पुरानी स्कूल" तालिका करने से कहीं अधिक अलग और जटिल अनुप्रयोग संभव हैं।

एक दृश्य-आधारित एनएसटीबल के अंदर मैं आसानी से नियंत्रण कैसे कर सकता हूं (संभवतया एक सेल में अन्य नियंत्रणों के साथ) एक ही क्लिक से पहले उत्तरदाता को देखें?

उत्तर

21

इस को हल करने के NSTableView पर इस विधि को ओवरराइड:

@interface NSResponder (NSControlEditingSupport) 

/* This is a responder chain method to allow controls to determine when they should become first responder or not. Some controls, such as NSTextField, should only become first responder when the enclosing NSTableView/NSBrowser indicates that the view can begin editing. It is up to the particular control that wants to be validated to call this method in its -mouseDown: (or other time) to determine if it should attempt to become the first responder or not. The default implementation returns YES when there is no -nextResponder, otherwise, it is forwarded up the responder chain. NSTableView/NSBrowser implements this to only allow first responder status if the responder is a view in a selected row. It also delays the first responder assignment if a doubleAction needs to (possibly) be sent. 'event' may be nil if there is no applicable event. 
*/ 
- (BOOL)validateProposedFirstResponder:(NSResponder *)responder forEvent:(NSEvent *)event NS_AVAILABLE_MAC(10_7); 

@end 

और हाँ लौट अभी firstResponder जल्दी से किए जाने के लिए अनुमति देने के लिए। तालिका में "देरी" पहली प्रतिक्रियाकर्ता बना रही है यदि कोई टेक्स्ट फ़ील्ड मारा गया था, और इसे तब तक बनाने की अनुमति नहीं देता जब तक पंक्ति पहले नहीं चुनी गई थी।

संबंधित मुद्दे