How to capture mouse click on Gtk.Stack - gtk

I would like to load the contents of a tab only when the user clicks on the same. Is there some property of the Stack or the Widget which I can use for this. I'm coding in Vala and I have currently worked around this by loading the content on the build of the UI. A sample piece of code will help a lot.
Thanks in advance !

Taken from OPs comment:
stack.add_titled (ports_layout_box, "my-tab", "FOO");
stack.notify["visible-child-name"].connect ((sender, property) => {
if ("my-tab" == stack.get_visible_child_name ()) {
// TO DO
}
});

Related

How to add popup in google vr view on the click of hotspot.

What I'm trying to do is, When I click on hotspot it should open a popup with little text. It is okay if the text is static, Is there any way we can make it possible? FYI I'm creating it for the web.
Thanks in advance:)
I just started with google VR. I know it's a late reply but it is very possible.
function onVrViewLoad() {
// init scene here and then:
vrView.on('click', onHotspotClick)
}
function onHotspotClick(e) {
console.log('onHotspotClick', e.id)
triggerSidebar(e.id)
}
function triggerSidebar(id) {
// add the class
switch (id) {
case 'item':
document.querySelector('aside.item').classList.add('...')
break
}
}

Transition from Launchpad to application sets focus on SearchField

we have the problem that a transition from the SAP Fiori Launchpad into our application sets the focus on the SearchField of the Master view.
It's a problem, because on mobile devices it triggers the activation of the keyboard which blocks the list view entries.
Any idea how to prevent that behaviour?
Directly entering the application is not creating this problem.
It's also happening in another Master/Detail application we created.
Across Android and iOS devices, replicated on Safari, Chrome, and Firefox.
Kind regards,
Michael
A bit late to the party but we had the same problem. Using onAfterRendering does work only once because that lifecycle hook gets only called once. To solve the issue do the following:
onInit: function () {
// onAfterShow hook gets called every time the view is shown
this.getView().addEventDelegate({onAfterShow: this._afterShow}, this);
},
_afterShow: function () {
jQuery.sap.delayedCall(0, this, function () {
jQuery('input').blur();
});
}
Hope that helps.
This is a workaround (the easiest solution I could Find as of now)
since I couldn't reproduce your issue :(
onDataLoaded() or in onAfterRedering() methods
//basically set the focus on something like this.. OR just create any SAPUI5 element and setVisible(false) and set the focus()
this.getList().focus();
UPDATE: Catch hold of search in getHeaderFooterOptions()
getHeaderFooterOptions: function () {
var _this = this;
var objHdrFtr = {
//sI18NMasterTitle: "YOUR_TITLE",
onRefresh: function (searchField, fnRefreshCompleted) {
_this._searchField = searchField;
}
};
return objHdrFtr;
}
then
onAfterRendering(){
if(this._searchField){
this._searchField.onAfterRendering = function() {
jQuery(this.getDomRef()).focusout()
};
}
}
Let me know if this works or not!
I will delete the answer.

can't tap on item in google autocomplete list on mobile

I'm making a mobile-app using Phonegap and HTML. Now I'm using the google maps/places autocomplete feature. The problem is: if I run it in my browser on my computer everything works fine and I choose a suggestion to use out of the autocomplete list - if I deploy it on my mobile I still get suggestions but I'm not able to tap one. It seems the "suggestion-overlay" is just ignored and I can tap on the page. Is there a possibility to put focus on the list of suggestions or something that way ?
Hope someone can help me. Thanks in advance.
There is indeed a conflict with FastClick and PAC. I found that I needed to add the needsclick class to both the pac-item and all its children.
$(document).on({
'DOMNodeInserted': function() {
$('.pac-item, .pac-item span', this).addClass('needsclick');
}
}, '.pac-container');
There is currently a pull request on github, but this hasn't been merged yet.
However, you can simply use this patched version of fastclick.
The patch adds the excludeNode option which let's you exclude DOM nodes handled by fastclick via regex. This is how I used it to make google autocomplete work with fastclick:
FastClick.attach(document.body, {
excludeNode: '^pac-'
});
This reply may be too late. But might be helpful for others.
I had the same issue and after debugging for hours, I found out this issue was because of adding "FastClick" library. After removing this, it worked as usual.
So for having fastClick and google suggestions, I have added this code in geo autocomplete
jQuery.fn.addGeoComplete = function(e){
var input = this;
$(input).attr("autocomplete" , "off");
var id = input.attr("id");
$(input).on("keypress", function(e){
var input = this;
var defaultBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(37.2555, -121.9245),
new google.maps.LatLng(37.2555, -121.9245));
var options = {
bounds: defaultBounds,
mapkey: "xxx"
};
//Fix for fastclick issue
var g_autocomplete = $("body > .pac-container").filter(":visible");
g_autocomplete.bind('DOMNodeInserted DOMNodeRemoved', function(event) {
$(".pac-item", this).addClass("needsclick");
});
//End of fix
autocomplete = new google.maps.places.Autocomplete(document.getElementById(id), options);
google.maps.event.addListener(autocomplete, 'place_changed', function() {
//Handle place selection
});
});
}
if you are using Framework 7, it has a custom implementation of FastClicks. Instead of the needsclick class, F7 has no-fastclick. The function below is how it is implemented in F7:
function targetNeedsFastClick(el) {
var $el = $(el);
if (el.nodeName.toLowerCase() === 'input' && el.type === 'file') return false;
if ($el.hasClass('no-fastclick') || $el.parents('.no-fastclick').length > 0) return false;
return true;
}
So as suggested in other comments, you will only have to add the .no-fastclick class to .pac-item and in all its children
I was having the same problem,
I realized what the problem was that probably the focusout event of pac-container happens before the tap event of the pac-item (only in phonegap built-in browser).
The only way I could solve this, is to add padding-bottom to the input when it is focused and change the top attribute of the pac-container, so that the pac-container resides within the borders of the input.
Therefore when user clicks on item in list the focusout event is not fired.
It's dirty, but it works
worked perfectly for me :
$(document).on({
'DOMNodeInserted': function() {
$('.pac-item, .pac-item span', this).addClass('needsclick');
}
}, '.pac-container');
Configuration: Cordova / iOS iphone 5

Autofocus does not work in form inside a partial view using MVC3 Razor

I am using MVC 3 Razor and I have a simple form in a PartialView [I am showing this as a popup window]. Some of the features are not working properly in PartialView. For example the autofocus attribute.
#Html.TextBoxFor(model => model.Code, new { style = "width:50px", maxlength = 4, autofocus = "" })
I have tried setting the focus through jQuery script but that doesn't work either.
$('#Code').focus();
Am I missing something? Do I have to import some scripts in my partial view for this to work?
Any help is greatly appreciated.
Thanks in Advance.
Update:
I found the problem... I was loading the window and then showing it after a delay of 700ms. I commented out the setTimeout line and it worked. It must be that the focus worked when form loaded but when I actually did the "open()" it lost focus again.
Previous Code
function openWindow(url, title) {
var window = $("#Window").data("tWindow");
window.ajaxRequest(url);
window.title(title);
setTimeout(showWindow, 700);
}
function showWindow() {
var window = $("#Window").data("tWindow");
window.open().center();
}
New Code
function openWindow(url, title) {
var window = $("#Window").data("tWindow");
window.ajaxRequest(url);
window.title(title).open().center();;
//setTimeout(showWindow, 700);
}
Thanks everyone for your replies. Hope it helps someone.
Try this code:
function openWindow(url, title) {
var window = $("#Window").data("tWindow");
window.ajaxRequest(url);
window.title(title).open().center();
//call after the content has been loaded from the Ajax request
document.getElementById('Code').focus();
}

Jstree dblclick binding problem [duplicate]

I try to use good lib jstree but i have some strange problem with dblclick binding.
Here is my code
$("#basic_html").jstree({
themes: {
url: "http://mywork/shinframework/shinfw/themes/redmond/css/jstree/default/style.css"
},
"plugins" : ["themes","html_data","ui","crrm","hotkeys", "core"],
});
$("#basic_html").bind("dblclick.jstree", function (e, data) {
alert(e);
alert(data);
});
When this code runs and i make dblclick for some node i can see 2 alerts. The first is object -right, the second is undefined - BUT i want receive data information.
Please, if some specialist solve this problem give me right way for correct use dblclick and receive "data" information about node who is i clicked.
Thanks
I recommend this approach . . .
$("#basic_html li").live("dblclick", function (data) {
//this object is jsTree node that was double clicked
...
});
First, you usually only need to know if the li was clicked so monitoring the event on the li will give you everything you need. Secondly, use live or delegate for the event binding so you can manipulate the tree without breaking the event.
Once you have the node that was double clicked (the this object) you can then use the built-in functions like this . . .
if (!jsAll.is_selected(this)) { return false; } //cancel operation if dbl-clicked node not selected
Where . . .
jsAll = $.jstree._reference("basic_html")
$("#basic_html").bind("dblclick.jstree", function (event) {
var node = $(event.target).closest("li");//that was the node you double click
});
that's the code you want.