How do I disable or remove the “replace” checkbox of NSTextFinder?

試著忘記壹切 提交于 2021-01-28 18:35:12

问题


My app displays a logfile in an NSTextView. I want the user to be able to search the output using the find bar, but not be able to replace any text. The NSTextView is set to be not editable, but when I press cmd-F, the find bar shows a "replace" checkbox:

enter image description here

I can prevent the user from being able to actually replace any text by implementing the NSTextViewDelegate protocol methods textView:shouldChangeTextInRange:replacementString: and textView:shouldChangeTextInRanges:replacementStrings: but this does not remove or disable the checkbox. How can I do this?


回答1:


NSTextFinder won’t present the Replace box if its findBarContainer’s editable property is NO (false).

You can set the property in code (the API is in the rarely-used superclass, NSText) or uncheck the box in Interface Builder.



来源:https://stackoverflow.com/questions/23620390/how-do-i-disable-or-remove-the-replace-checkbox-of-nstextfinder

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!