Can you add to GestureRecognizer of the same type to one view? - uitextview

I need to detect long-press on a UITextView, which already recognises long-press thus it has a long press recognizer, can I create a new one and add to it? How will it work then, two recognizers will get the same callback when you long-press?
Thanks!

Just add two UILongPressRecognizers with different selectors (initWithTarget:selector:) to the view. It should work just like you think it will work. You may need to return YES from your delegate's -gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer: when both of your UILongPressRecognizers are invoked simultaneously.
Note that you will likely encounter problems with Apple's recognizer for popping up the magnifier loupe.

Related

Primefaces autocomplete enter key behavior

when we type into autoComplete, primefaces automatically highlighted first shown item. so when we press enter key that item will be selected. how can i change the behavior of enter key, so when it pressed, just entered text be submitted in backing bean property.
I know we can hit ESC button then continue but but user don't like it.
I am using primefaces 5.0 & jsf 2.1.11
What helped me to solve the same issue where the answers here and here. Basically, you have to override 2 different behaviours.
First one is the default selection of the first result, that can be achieved adding this to your autocomplete (as stated by the accepted answer in the first link, available in primefaces for versions 5.1.5, 5.0.14 and 5.2):
autoHighlight="false"
The second thing you want to override is the behaviour when Enter is pressed, as you want the form that contains the autocomplete to be submitted. For doing so, just add this code to either the containing form or the autocomplete:
onkeyup="if (event.keyCode == 13) {
document.getElementById('[searchFormId]:[submitButtonId]').click();
return false; }"
Change the ids between square brackets for your own ones and it's done.
PS: I know this is a rather old question but it still applies to the current version of primefaces (6.1 when this question was answered). And I also think it can help to have both changes combined in one answer.
Truth be told, this feels like a bug. Richfaces do that implicitly (submit on enter while suggesting). I haven't found an official fix so I did some research and turns out the simplest way is to override the JS function that resolves key presses. The whole autocomplete js is here. You just need to override the bindKeyEvents function so you declare it likewise:
PrimeFaces.widget.AutoComplete.prototype.bindKeyEvents = function () {
Then add the rest of the code for this specific function from the JS I mentioned before. I've omitted that code so it's more readable. Then you want to find a switch that resolves different keys that have some behavior mapped to them. And under the code:
case keyCode.ENTER:
case keyCode.NUMPAD_ENTER:
Add something like:
if (highlightedItem.length == 0) {
document.getElementById("<your_form_id>").click();
_self.hide();
} else {
highlightedItem.click();
}
Also, make sure that you got forceSelection and the autohighlight off on the autocomplete component.
The problem in the JS is that even though you haven't selected any item from the suggestions it still triggers the event that tries to click the item... which doesn't even exist.
This is the simplest way as I said... you can also create your own autocomplete implementation and override the behavior there. But that's a lot of work and if you only need this one feature I suggest overriding the JS function.
In order to override the original JS with your custom one you need to make sure yours is loaded after the original one. To do that you can either use h:outputScript or simply just load the javascript like you're used to... but in the body (not the head).
Also there's probably a fancier way than having to specify the form id. But I just wasted too much time searching for a solution that I had to get it done real fast.

Why would I not want to delete a panel when I remove it from a category?

I was looking at the function CMFCRibbonCategory::RemovePanel and I saw something that I don't understand. The 2nd optional parameter is bDelete which according to the docs:
[in] bDelete
TRUE to delete the panel object from memory; FALSE to remove the panel object without deleting it.
I don't see a way of referencing the same panel elsewhere and this isn't like hiding the panel as there is no way to bring it back, so why wouldn't I want to do this?
Unless this is in case I were to keep a live pointer to it using CMFCRibbonCategory::GetPanel? Sounds kinda like a bad idea.
I agree. There is no real use for Setting bDelete to false at all.
m_arPanes is no where accessed in a way that some one can add a Panel with a plain pointer.
It seams to be a relict when they transported the BGC ribbons implementation into the MFC. The BCG version also have this bDelete flag and it isn't useful there too, but there are more complex functions that handle such panels.
But I don't see this functions and internal customizable panels in categories in the MFC.
So from the design point it would have been better to create a special protected function like InternalRemovePanel. That just remove th Panel and keps the pointer...

Coded ui objects in UIMap

I have a question regarding coded ui UIMap.
Every time I record an action on the same application, coded ui generates a new object for the same window in the application.
It looks like:
UIAdminWindow
UIAdminWindow1
UIAdminWindow2
and so on...
every window class holds different buttons, even though it's the same window.
Thus it's very hard to keep code maintenance.
What i would like is that every time i perform actions and records on a window, even if not at the same time, the already generated class for this window, will be updated with the new controls.
any suggestions to why it happens?
Thanks a lot!
You can clean up your UIMaps by doing two things:
Use the UIMap Toolbox (from codeplex) to move controls within the UIMap so they are all under one control tree.
When you have duplicate UI controls, go to the properties for the action that references the duplicate control and change the UI Control property to point to the original control in the UIMap.
The duplicate trees should now be unreferenced and you can delete it from your map, keeping things clean.
And yes, it's a pain to do, but it's worth it for maintainability.
In UIMap.uitest you can change the action name and the control name for better maintenance.
For example: you can set UIAdminWindow as FirstAcessWindow or other name that will express comfortably the control or the action.
What I can guess is that there is some randomly generated content or element identification data such as class or title that may be causing it. This may be caused by different username for example. Also you can update the element from UI map element tree.

wxgrid , Detecting Scroll event

I have created a wxGrid with custom table. Whenever the user scrolls down to very bottom of the grid, I have to load the next 100 rows from my table. I tried EVT_SCROLL_BOTTOM() but I am not able to detect it. What is the right thing to do? Thanks.
I don't know the answer to your question but I am reminded that the grid was designed to work with an object of type wxGridTableBase that can be extended by the application. By extending this class, you should be able to do whatever caching you want inside of the extended object.
You could bind the scroll win event for the grid. I have encountered almost the same requirement as you. :)
self.Bind(wx.EVT_SCROLLWIN, self.OnScroll)

Core data dirty flag not being set

I have a core data document based cocoa app that is working well except for one slightly odd problem.
For some reason, if I make a change to any of my fields the menu/window don't seem to recognize it - ie. the red close button doesn't get the black 'dirty' indicator and the File/Save menu item isn't enabled. However, if I attempt to close the application (via command-Q), I do get the popup asking me if I want to save my changes.
It seems that the document's dirty flag is being set, but the window/menu items aren't reacting to it. I am curious as to where I might look to see why this might be the case. I suspect that it may have something to do with my window not knowing about my ManagedObjectContext...
The only slightly atypical behaviour is that my document's makeWindowControllers method has been overridden and I am adding my window controllers using a call to my document's [self addWindowController:xxx] method. My window controllers subclass from NSWindowController so I had to add my own instance variable to each window controller to hold the ManagedObjectContext, but I suspect that this isn't getting passed to the window/menu. Not sure what the normal pattern is here...
Anyway, any thoughts would be much appreciated. Thanks
From the description it sounds like your UI elements are not actually bound to the document itself. If so, then the UI elements are not observing the document and are not reacting to changes in the document. Check the bindings.
Thanks in part to TechZen, and also re-reading my own question (in particular, where I said "I suspect that it may have something to do with my window not knowing about my ManagedObjectContext") I started to look at the bindings for my WindowController subclass.
As it turned out, I hadn't bound the window outlet for the File's Owner to my actual NSWindow. As soon as I did that, the black dirty dot and the window's menus started behaving correctly.

Resources