We're currently developing an Xbox One and a Windows 8.1 app, which share the same codebase, and I'm running into an issue with the 'pointerover' (or hover-state) in of a listView item in the WinJS.UI.ListView.
The listview item has an eventListener, pointerover. However, this only seems to work on the first 10 items in the WinJS.UI.ListView although I see 16 items on screen, and the WinJS.UI.ListView gives me:
indexOfFirstVisible = 0
indexOfLastVisible = 15
The eventListener my listItem has, is:
mediaTile.element.addEventListener("pointerover", function (that) {
that._allItemsListView.currentItem = { hasFocus: true, index: this.tileIndex };
}.bind(mediaTile, this));
When I add a breakpoint, it get's hit but only for the first 10 items although there are 16 items on screen.
Does anyone know what I'm missing here?
Thanks in advance!
My guess is you're getting bitten by ListView visualization. Perhaps tiles higher than 10 don't yet exist when you bind your event listener, but they appear on screen quickly enough that it isn't obvious.
I'm not expert enough to advise a concrete way around this. Conceptually you could listen for an event when new items are added to the list (on the list itself) and then add your pointerover event to the new items.
Yes, that seemed to be the case when you look at it from a distance; another developer took over, and we also migrated from WinJS 1.0 to WinJS 2.0, which seems to solve a lot of these problems.
Up until today I'm not sure what the exact problem was; we also played with the fetch limit of the datasource and this also seem to have played a part in solving the problem.
I'm sorry I can't be more thorough in my answer; I would have to ask the developer (if he still remembers) what the problem was, but afaik the major improvement was moving to WinJS 2.0.
Related
Further to my earlier question
Migrating iOS Hybrid App from UIWebView to WKWebview
I have made good progress and only have a few loose ends to tidy up. The overall performance improvement over UIWebView is outstanding.
In UIWebView it was possible to set the focus on a text field programatically using
webView.keyboardDisplayRequiresUserAction = NO ;
However this is not available in WKWebView and ever since 2016 programmers have been developing an updating work arounds (swizzles) to overcome this.
I have tried implementing the latest of these I could find on Stack Overflow, which I found at https://stackoverflow.com/a/55344531/5948260
However as I am very inexperienced at coding in XCode please could someone tell me exactly how I add the above solution to my project. I have tried in vain to find examples of how exactly to do this i
on GitHub or elsewhere but to no avail.
So far I have tried copying the code provided in the above answer into a .m file and adding it to my project, but I got 20 or so errors, I then added an import statement for Foundation and most of these went away but XCode complained that it did not know what class WebViewInjection is. Also must there be a corresponding header file?. Must there be a corresponding interface statement? How does the method defined in the answer get invoked?
As I could not answer any of these, I also tried adding the method into my ViewController class. Whilst this was accepted with no errors, it had no effect on my app, ie. the keyboard did not come up automatically.
I would also want the webview to resize to appear above the keyboard and not to scroll to where the text field is as this seems a very messy solution to me.
All help very gratefully received.
I have now managed to get the keyboard displayed by adding
[self allowDisplayingKeyboardWithoutUserAction];
to viewDidLoad
I kept the allowDisplayingKeyboardWithoutUserAction method declaration inside my ViewController but changed the + infront of the method declaration to a - and this seems to have worked.
I still do not know how to resize the webview when the keyboard is displayed.
I'm working on an app that'll have a range of images and the collectionview is not showing up at all. I was following this article, which I translated to C#.
here is an example app I made to show a minimal example of what I'm trying to do.
When I run through the code, GetCell in the collection source isn't firing which I know is the problem, but I don't know why it's not firing and I'm simply at a lost on what I'm missing.
I test it again today and I can make sure that the problem is caused by the MosaicCollectionLayout.
What I did today is that I removed your collectionView and add a new collectionView, then I add Constrains to it with a fixed height and width(to make sure it appears even if there is no data), then I change the layout to FlowLayout, it works, here is the screenshot:
After that, I changed the layout back to MosaicCollectionLayout, I get an exception in the line _cachedAttributes.Reverse(lastIndex.Row, firstMatchIndex.Value); inside the method LayoutAttributesForElementsInRect.
I checked the article and did not find a solution yet. Maybe there is some mistakes in the codes translated from swift to C#. So the problem is not related to the xib, please check the code in the method LayoutAttributesForElementsInRect.You can also try add Constrains to your collectionView. Hope these information helps you.
First of all sorry if this question has been already asked somewhere, but after a few hours on google I still can't find an answer.
I am pretty new in portlet development, (but we have a shortage of developers and I have to work with it time to time), so the solution might be something trivial, but I really don't have enough experience with it.
The problem is I have two portlets on a page and I try to let one of them know about changes in the other. For this I use IPC. In the first one I have a Liferay.fire function:
function fire(key,value){
Liferay.fire(
'category',{
id: key,
name: value
}
);
}
In the other I have a Liferay.on('category',function(category){...}) function with an ajax call inside and some rendering methods.
Now if I visit the mentioned page and click on the corresponding buttons, at first everything works just fine. However, if I navigate from this page and come back, the listener will run two times. Navigating again -> three times. And so on... But if I reload the page (with F5 or CTRL+F5), it starts over, so until further navigation the listener runs only once.
The other strange thing is no matter how many times the function runs, the input parameters are all the same for each.
For example, if I have left the page and went back to it 3 times and last time I chose the category with 'id=1', then the function will run 3 times with 'id=1'. Now if I choose 'id=2' it will run 3 times with 'id=2'.
If anyone has any idea I would be really grateful as I am stuck for almost a day now.
Thank you very much in advance and please let me know if you need any further info.
the problem you're having is caused by the global Liferay.on listeners that are being created but never removed.
In Liferay Portal 7.x, SPA navigation is enabled by default. This means that when you are navigating, the page isn't being completely refreshed, but simply updated with new data coming from the server.
In a traditional navigation scenario, every page refresh resets everything, so you don't have to be so careful about everything that's left behind. In an SPA scenario, however, global listeners such as Liferay.on or Liferay.after or body delegates can become problematic. Every time you're executing that code, you're adding yet another listener to the globally persisted Liferay object. The result is the observed multiple invocations of those listeners.
To fix it, you simply need to listen to the navigation event in order to detach your listeners like this:
var onCategory = function(event) {...};
var clearPortletHandlers = function(event) {
if (event.portletId === '<%= portletDisplay.getRootPortletId() %>') {
Liferay.detach('onCategoryHandler', onCategory);
Liferay.detach('destroyPortlet', clearPortletHandlers);
}
};
Liferay.on('category', onCategory);
Liferay.on('destroyPortlet', clearPortletHandlers);
The whole day I am trying to solve this simple issue, but without any success.
I found a lot of hints in internet, but seems, that none of them is valid for my problem.
My issue is quite simple: I want to change the caption of a menue item while runtime
But it seems, that all solutions I found are very specific.
My requirements are this:
- it is a MFC application (VS2010)
- It is a SDI application, not MDI
- I want to change the caption of a main menu item (like "File"), not an entry of a submenue.
Because of main entry item, there is no ID for the menu item. Therefore solutions with ON_UPDATE_COMMAND_UI will not work!
My problems are:
- either the code I tried, is generating an assertion or exception
- or the function call returns with false
- or the function seems to work well, but I do not see any result (the caption is still unchanged)
Maybe I am using the wrong functions, or the wrong place for calling the functions.
Has anybody an example, which would work within my application pre-conditions?
Many, many thanks!
Richard
Windows cleverly hides the function to modify a menu under the arcane name of ModifyMenu. I hate it when they do things like that. Really makes me wish for Linux/Unix, with nice clear names like shmdt and mvwaddchnstr. Anyway, getting off my soap box for the moment, you'd call it something like this:
GetParentFrame()->GetMenu()->ModifyMenuW(1, MF_BYPOSITION, 0, L"New Item");
GetParentFrame()->Invalidate();
I am using jquery in my web page. I see a lot of memory leak happening and after a while the whole browser grinds to a halt. I used the sieve tool and noticed that there is a contsant increase in the no. of DOM elements, everytime by a no. of 4.
Am I doing something wrong in the way I have associated events?
Or is it because I am using setTimeout to redraw my app every X seconds?
Event association:
$('.bir_Names').click(showNames);
The selector $('.bir_Names') evelautes to a set of some 300 elements each of which call the function on click.
setTimeout
Every X mins I remove every single HTML element in the app and rebind fresh data and associate the events. I use jquery remove() to delete elements. have tried innerHTML = '' and empty() also.
I see a jump of nearly 30-40 MB for every redraw and Sieve indicates that none of the deleted nodes are actually removed.
Anyhelp would be greatly appreciated. This thing is driving me nuts.
Thanks.
You don't mention which browser, but some googling seems to indicate that this is a known problem with IE. Here's one potential workaround:
http://forum.jquery.com/topic/possible-memory-leak-in-remove-and-empty
Note that that's referring to a 1.2.x release of jQuery. Before you do anything, make sure you are running the latest 1.6.x release to first see if the defect has already been fixed within jQuery.
[EDIT] ack...you DO state your browsers...'all'...so maybe disregard that first link.