I've been trying to change the cursor on Gtk.ScrolledWindow() (it has an image widget in it) mouseover:
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk, GdkPixbuf
class MainWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title = "Test")
self.maximize()
grid = Gtk.Grid()
self.add(grid)
scrolled = Gtk.ScrolledWindow()
scrolled.set_hexpand(True)
scrolled.set_vexpand(True)
scrolled.connect("motion-notify-event", self.mousemove)
grid.add(scrolled)
pixbuf = GdkPixbuf.Pixbuf.new_from_file("anyimage.jpg")
image = Gtk.Image.new_from_pixbuf(pixbuf)
scrolled.add(image)
def mousemove(self, widget, event):
print("Mouseover triggered")
circle = Gdk.Cursor(Gdk.CursorType.CIRCLE)
widget.get_window().set_cursor(circle)
win = MainWindow()
win.connect("destroy", Gtk.main_quit)
win.show_all()
The event is triggered but instead of a circle the cursor is displayed as an arrow with a "disabled" symbol as its subscript.
Am I missing something here?
I was wrong, it's not a bug. It's entirely up to the cursor theme in use. I was recommended to stick to cursors listed by name here:
https://developer.gnome.org/gdk3/3.24/gdk3-Cursors.html#gdk-cursor-new-from-name
Those correspond to CSS and are most likely to be available across cursor themes.
Related
In iOS 10 one can set the tint color of the navigation bar for all the app using this line of code:
UINavigationBar.appearance().barTintColor = UIColor.green
However when the same is done in iOS 11, it seems to also affect system views. For example, when showing a UIActivityViewController with this code:
let titleText = "SOME TITLE"
let urlStr = "https://google.com"
let activityItems = [titleText,urlStr]
let activityViewController = UIActivityViewController(activityItems: activityItems, applicationActivities: nil)
And selecting the "Add to Notes" option, the navigation bar is shown with the previously set color (green in this case)
I would like to ask, is this is a bug or is it intended?
(I already filed a bug report to apple a little over a month ago but didn't get a response)
Here is a screenshot of the issue:
Why not simply Subclass UINavigationController and set the appearance proxy like so?
UINavigationBar.appearance(whenContainedInInstancesOf: [YourUINavigationControllerSubclass.self]).barTintColor = UIColor.green
This a lot less hacky and it will solve the issue without any negative effects.
You can find a bit more info on the subject here.
I am working on an Augmented Reality iOS app for which i am using ARKIT of iOS 11 beta. I am using ARSCNView(SceneKit) to render my .scn object. I have followed the sample given by apple in order to create an ARSession(https://developer.apple.com/sample-code/wwdc/2017/PlacingObjects.zip). Is it possible to place the 3D model with custom background instead of camera?
Like user can select the background color or can provide custom 2D photos as background?
Your view has a scene property where you can set the background to a color or an image:
view.scene.background.contents = UIColor.red
let myImage: UIImage = ...
view.scene.background.contents = myImage
I use shake motion callback of UIKit to change background contents. As #yaali said, CameraContents is used to store camera contents. Notice that we can't get background.contents if the camera has not launched, for example on viewWillAppear. I guess ARKit set the AVCaptureVideoPreviewLayer to ARSCNView.scene.background.cocntents.
override func motionBegan(_ motion: UIEventSubtype, with event: UIEvent?) {
if CameraContents == nil {
CameraContents = sceneView.scene.background.contents;
return
}
if cameraBackGround == true {
sceneView.scene.background.contents = "Background_sky.png"
}else{
sceneView.scene.background.contents = CameraContents
}
cameraBackGround = !cameraBackGround
}
we want dialog message in this format and look and fill
Can you please let me know how to resolve it. My application needs to be supported on all platforms (Android, iOS, Windows) and I don't want to write native code for all platforms separately.
Actually customizing the look is easier in Codename One as everything is written in Java you can customize literally everything about the look of anything.
For simplicity sake I used code rather than styles which would be better, you can customize the Dialog UIID and other UIID's in the theme designer to get more flexibility and have this easier. However, this would require many screenshots and explanations so I did the customization in code:
Form f = new Form("Test");
Button b = new Button("Show Dialog");
f.add(b);
b.addActionListener(e -> {
Dialog dlg = new Dialog("Authentication");
Style dlgStyle = dlg.getDialogStyle();
dlgStyle.setBorder(Border.createEmpty());
dlgStyle.setBgTransparency(255);
dlgStyle.setBgColor(0xffffff);
Label title = dlg.getTitleComponent();
title.setIcon(finalDuke.scaledHeight(title.getPreferredH()));
title.getUnselectedStyle().setFgColor(0xff);
title.getUnselectedStyle().setAlignment(Component.LEFT);
dlg.setLayout(BoxLayout.y());
Label blueLabel = new Label();
blueLabel.setShowEvenIfBlank(true);
blueLabel.getUnselectedStyle().setBgColor(0xff);
blueLabel.getUnselectedStyle().setPadding(1, 1, 1, 1);
blueLabel.getUnselectedStyle().setPaddingUnit(Style.UNIT_TYPE_PIXELS);
dlg.add(blueLabel);
TextArea ta = new TextArea("This is the text you want to appear in the dialog, this might line break if the text is too long...");
ta.setEditable(false);
ta.setUIID("DialogBody");
ta.getAllStyles().setFgColor(0);
dlg.add(ta);
Label grayLabel = new Label();
grayLabel.setShowEvenIfBlank(true);
grayLabel.getUnselectedStyle().setBgColor(0xcccccc);
grayLabel.getUnselectedStyle().setPadding(1, 1, 1, 1);
grayLabel.getUnselectedStyle().setPaddingUnit(Style.UNIT_TYPE_PIXELS);
dlg.add(grayLabel);
Button ok = new Button(new Command("OK"));
ok.getAllStyles().setBorder(Border.createEmpty());
ok.getAllStyles().setFgColor(0);
dlg.add(ok);
dlg.showDialog();
});
f.show();
I would recommend doing the dialog customization in the theme designer and using a 9-piece image border which is better looking.
I want to add a button that show/hides the popover, similarly to the one of the DropBox app.
(In both landscape & portrait)
I have tried many solutions, but at this stage I don't even want to muddy the water with my attempts. If you've done this, or know how to do this, please send me in the right direction!
Thanks!
it appears it's quite simple.
Set some object to be delegate of splitViewController. In my case (I create all viewcontrollers programatically) that was appdelegate.
UISplitViewController* splitViewController = [[UISplitViewController alloc] init];
[splitViewController setViewControllers:#[navigationViewController1, navigationViewController2]];
splitViewController.delegate = self;
Implement delegate method to hide master in portrait orientation:
- (BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation {
return UIInterfaceOrientationIsPortrait(orientation);
}
Actually add barButtonItem:
-(void)splitViewController:(UISplitViewController *)svc
willHideViewController:(UIViewController *)aViewController
withBarButtonItem:(UIBarButtonItem *)barButtonItem
forPopoverController:(UIPopoverController *)pc {
UINavigationController* slaveNavigationViewController = svc.viewControllers[1];
UIViewController* slaveViewController = slaveNavigationViewController.viewControllers[0];
[barButtonItem setTitle:#"Your master title"];
slaveViewController.navigationItem.leftBarButtonItem = barButtonItem;
}
In this method, you get barButtonItem which you customize and add to slaveViewController.
And last one, remove the button in landscape orientation:
- (void)splitViewController:(UISplitViewController *)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {
UINavigationController* slaveNavigationViewController = svc.viewControllers[1];
UIViewController* slaveViewController = slaveNavigationViewController.viewControllers[0];
[barButtonItem setTitle:#"Drops"];
slaveViewController.navigationItem.leftBarButtonItem = nil;
}
That's it.
There's a simpler, undocumented way to do it. For an existing UIButton:
[button addTarget: theSplitViewController action: #selector(toggleMasterVisible:) forControlEvents:UIControlEventTouchUpInside];
This target/action are the same as for the barButtonItem sent in the willHideViewController function.
I integrate the iCarousel app with single view application.But when I add the tab bar controller and place this iCarousel code in one tab bar Item viewcontroller.But it does not work(Items are displayed but not scrolled).What is the problem here.
I created iCarousel as below:
iCarousel *categorySubView = [[iCarousel alloc]initWithFrame:CGRectMake(0,200, 300, 125)];
categorySubView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
categorySubView.delegate = self;
categorySubView.dataSource = self;
categorySubView.type=iCarouselTypeRotary;
[self.view addSubview:categorySubView];
I am using the following delegae and data source methods:
-(NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel
{
return 5;
}
- (UIView *) carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view{
UIView *sampleView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 250, 300)];
sampleView.backgroundColor=[UIColor whiteColor];
UILabel *labelis=[[UILabel alloc]initWithFrame:CGRectMake(10, 10, 100, 20)];
labelis.backgroundColor=[UIColor clearColor];
labelis.text=#"8Apr-14Apr";
[sampleView addsubView:labelis];
return sampleView;
}
Please suggest me.
Thanks inadvance
I notice that your carousel view is much smaller than the size of the items inside it (it's only 125 points high).
iCarousel can draw outside of its bounds, but it cannot detect touch events outside of its bounds, so that might be why you are having trouble scrolling.
A good way to debug this is to set the carousel.clipsToBounds = YES, that way what it draws will match what is touchable. Another option is to set the carousel.backgroundColor so you can see what part of it is touchable on screen.
Another thing to check is that the view that you've placed the carousel inside has userInteractionEnabled set to YES.