I am new to Gtk# and Monodevelop. So please forgive the basic-ness of this question. But I am trying to do something really simple - and I can't seem to do it. Not sure if it matters, but I am developing on Linux
I have a MainWindow which has a button. When I click on this button, I want a custom widget to pop-up
I created a custom widget as a separate project, compile it as a .dll and refer it in the main project
In the main project, I have defined a call-back for button click - loadCustomWidget()
However, the code below does not show the custom-widget on screen
public partial class CustomWidget : Gtk.Bin ; // in the other project
protected void loadCustomWidget() {
Console.WriteLine(" show custom widget ") ;
wg = new CustomWidget() ;
wg.Show() ;
}
The WriteLine() is printed. So I know the call-back is being called. But why isn't the widget showing on screen?
You need to put the widget into a container, for example add it to your main window.
Related
I have created a CustomMapRenderer on my Droid project to deal with the map custom rending and display of custom Pin and Info Window. This is all working fine and in my function
public Android.Views.View GetInfoContents(Marker marker)
I can show the info text using the MapInfoWindow.axml
However I have an issue that on the form I have a Button and I want to be able to hook in to the on click event on that ImageView but I notice that click event is only available on the complete InfoWindow and there is no way to specifically track the click on the individual item on that window.
I tried to use the following code to check:
callImage.Click += (s, e) =>
{
Xamarin.Essentials.PhoneDialer.Open(PinCustom.MobileNo);
};
the call always reaches
NativeMap.InfoWindowClick += OnInfoWindowClick;
can someone please help in hooking on to the individual item click instead of working with the complete InfoWindow?
it seems could not respond the click event of ImageView.
An info window is not a live View. Instead, Android will convert the
View to a static bitmap and display that as an image. This means that
while an info window can respond to a click event, it cannot respond
to any touch events or gestures, and the individual controls in the
info window cannot respond to their own click events.
you could refer to Custom the Info Window
How can we navigate to other page on click on button in user control in windows store app? I tried by making a new frame object and calling navigate method, but no luck till yet.
thanks.
The Frame is a ContentControl that hosts the pages. If you want to navigate back and forth between pages you need to use a single Frame control. The default one is created in the App class in the default Visual Studio templates. You can save the instance reference of that Frame like by having a static property on the App class like: public static Frame RootFrame { get; private set; } and then set it where it is constructed - App.RootFrame = new Frame(). Then you can navigate simply by calling App.RootFrame.Navigate().
I am developing a Wordpress Theme that includes a custom Widget, everything works out fine but there is one thing I do not know how to implement correctly:
I would like to run some Javascript after the Widget Instance was created in the admin panel, that means in the very moment after the widget was dropped in a sidebar, not after saving.
I have no Problems with running JS after the page was loaded or the Widget was saved, I want to run Javascript after the User just dropped a new Instance into the side bar, what actually can happen more than once without page reload.
Greetings philipp
Another way of doing this I just figured out --
I'm going to show a more complex example involving dependencies, though realise the bit in Custom_Widget::form() is the real answer to the question:
function add_js_deps() {
if (is_admin()) {
wp_enqueue_script('jquery-ui-accordion');
}
}
add_action( 'init', 'add_js_deps' ); // "init" because wp_enqueue_scripts is too late.
// Then in the widget....
class Custom_Widget extends WP_Widget {
public function form($instance) {
/** Collapsing accordion-y form HTML here **/
wp_enqueue_script('custom-js', plugins_url('js/my.js', __FILE__), array('jquery-ui-accordion'), '1.0.0', true);
}
}
I'd argue this is the better route as it has dependency management and you won't have a bunch of JavaScript mid-way into your DOM. Using wp_enqueue_script is generally always the more WordPressian way of doing things regardless.
Place a script tag in the widget form function.
function form($instance)
{
?><script type="text/javascript">console.log("firing javascript");</script>
<?php
//form details...
}
I eventually went a different way with this. Loaded our plugin admin script on the page using wp_enque_script and then just used jquery selectors and an event handler to target the right widget.
$('div.widgets-sortables')
.on('sortstop', function (event, ui) {
// only if this widget has the proper identifier...do something
if (ui.item.find('.my_widget').length == 0)
return;
run some function...
Still not my favourite technique...but it is cleaner then coding it in the widget. Does require a variable to track created widgets and using the "this" variable is useful
I built a simple hello world app to check out the Flash Builder 4.5 mobile capabilities.
Here's how it works:
The Default View asks for name in an textinput and has a continue button
When you click the continue button it pushes a new view in the viewNavigator which just displays "Hello " + name in a label.
When you click anywhere in this view, it pops a view (i.e. itself) from the viewNavigator, to go back to the default view
I see only 1 issue with this:
When I get back to the default view, it is in its initial state, i.e. the textInput is blank. It seems as if the viewNavigator created a new view of the default view's class and pushed this, instead of just removing the top view and displaying the previous one.
I see this being especially problematic for programs which display data in a grid and you can click the data to view the detail...when you get back, the grid will be empty.
Any ideas or gotchas to solve this?
EDIT:
Project name: HelloWorld
Code below:
HelloWorldDefaultView.mxml
protected function button1_clickHandler(event:MouseEvent):void {
navigator.pushView(HiView, tName.text);
}
HiView.mxml
protected function view1_clickHandler(event:MouseEvent):void {
navigator.popView();
}
protected function view1_creationCompleteHandler(event:FlexEvent):void {
lblHello.text="Hello " + data;
}
Screenshots
Initial screen
Screen 2
Clicking on screen 2 gets us back to initial screen. Notice the blank textInput
Have you tried to set destructionPolicy="never" and then
protected function button1_clickHandler(event:MouseEvent):void {
data = tName.text;
navigator.pushView(HiView, tName.text);
}
to store the data in current View's data - before changing to another one?
That's the way it is supposed to work for mobile applications.
Check out this article: Flex 4.5 (Hero) – Persistant Data in MobileApplication
As they write:
Each time a View is removed from the display list (via popView() or pushView()) its instance is destroyed, but its data model is stored in memory.
In order to save session state for a View, you must modify the data property. This property will be requested when destroying the current instance of the View class. And the data property value will be assigned back to a newly created instance of the same View class when navigating back to that view.
I am a beginner in java swing.
I have just created my first login screen using netbean.
I like to ask after my actionPerformed if say login successfully. How do i actually go to the next screen? As in coding wise how should i code or netbeans got something build in for this
You should have a new class that extends Jframe called something appropriate (MainWindow maybe) that gets created when the user enters the correct password, so probably in the eventListener code for the button
if (usernameAndPasswordCorrect()) {
loginWindow.setVisible(false);
loginWindow.dispose();
MainWindow w = new MainWindow();
w.setVisible(true);
}
else {
JOptionPane.showMessageDialog(loginWindow, "Incorrect login information. Try again.");
}
Or something like that.