Show Gtk.Popover at cursor of Gtk.Entry - c

I want to to show a Gtk.Popover at the position of the cursor of a Gtk.Entry. I'm only only able to add the popover relative to the entry itself, but the Gtk.Popover appears at the center of the Gtk.Entry everytime.
Is there a way how I can get the position of my Gtk.Entry cursor and create the popover at this position?

You should set the widget to which your popover is relative to, by using Gtk.Popover.relative_to; then you can use Gtk.Popover.pointing_to and the rectangle with the location of the cursor. To get that, use Gtk.Entry.cursor_position to retrieve the index of the cursor in characters and transform it into a location within the Pango.Layout of the Gtk.Entry widget; if the entry is allowed to scroll, you should also get the Gtk.Entry.scroll_offset and subtract it from the coordinates returned by Pango.

Related

WPF drag and drop not working with empty image

I want to allow the user to drop an image from explorer onto an empty Image(Source property not set), and I want the Image to be empty by default, but the Drop event will not fire if the Image is empty and my cursor will just be a circle with a slash. I tried adding a default image to the Image and it worked just fine. Is there any way I can make this work or are there any workarounds?
try put a layout container, such as Grid, outside the Image control, set it to be transparent, and then handle the drop event in the container

Draft.js get selection or span for already styled elements

I'm using react-rte but am willing to extend it so let's talk about Draft-js.
I need to be able to "inline-style" a selection. Then on subsequent renders re-access that selection's dom.
So let's say I highlight a selection. Then I persist the document. Then I come back, reload the document, I need to be able get access to that highlighted section, but in the dom.
Basically on the side of the document I'm applying markers, outside of draft-js, and those markers need to line up with the highlighted part. So when I do the initial highlighting I can get the dom position from window.getSelection(), and i can place my marker. But the dom may change later and I won't be able to place my marker.
--edit--
So another use case is that I highlight a selection, and even in the same session, I need to change the color of the selection programatically so again I need to access the section of the document even if the cursor is not on that section.
--end edit--
So what I really need is something like an unique classname, id or even better a react ref for the new spans that are created when you do an inline style.
Please let me know if you need a better explanation.
The SelectionState records the selection, including start block, start offset, end block and end offset. It's not problem to save the selection in you code and apply to the editor later.
So what I really need is something like an unique classname, id or even better a react ref for the new spans that are created when you do an inline style.
So the id you want is a SelectionState, tell where the span is in draft-js editor.
UPDATE
You can find the block key which your inline styled text belongs to, in data-offset-key={blockkey}-xx-xx node attribute. The block key helps you find the node from SelectionState.getStartKey()/getEndKey(). Then find the span node by SelectionState.getStartOffset()/getEndOffset().

How-to select dynamic nodes in Polymer?

I am trying to set up mouse events for an element stamped out by dom-repeat. The event should trigger a style change for a different element in the dom-repeat template, basically just a color change for an icon in a box on a box hover.
As automatic node finding is not available for dynamic nodes, the docs say I should use the $$ selector.
However, $$ only returns the first node in the local DOM that matches selector, and I want the hover effect for all boxes stamped out by the dom-repeat.
As $$ selects an element's property, that leaves me thinking I would need to set up a dynamic attribute for the icon from the dom-repeat, so that I can select every repeated icon instance in the mouse event change functions.
The repeater gives me the index, but how would I set a dynamic property with it, instead of a dynamic value?
What am I missing?
This should do what you want:
var nodes = Polymer.dom(this.root).querySelectorAll(...)
If you modify the DOM you might need to use the Polymer.dom(...) API for the individual nodes you are modifying.
Polymer.dom(nodes[i])...

Extjs look and feel

I have very simple grid which contains a lot of data - so my scroll ball is quite narrow. I edit data in cells. Left to my grid there is picture with coordinates points. I wish this behavior: when I click on coordinate point I want to go to corresponding grid row. They are related by id(id row = id point div). How can it be made?
Also when I edit grid in the middle and bind coordinates of new point to row(by using store) - the grid gets automatically reloaded after store is updated - and scroll gets to the top. How can I track last edited row in the middle of the list so I can auotmatically focus on it? Thanx in advance.
use the focusRow method (http://docs.sencha.com/extjs/4.2.3/#!/api/Ext.view.Table-method-focusRow) to scroll where you want, for example :
yourGrid.getView().focusRow(10);
To disable the 'scroll to the top" effect when you reload the grid, set preserveScrollOnRefresh to true on the viewConfig of your grid (http://docs.sencha.com/extjs/4.2.3/#!/api/Ext.view.Table-cfg-preserveScrollOnRefresh).

GTK: positioning context menu items w.r.t context menu

I am working on a defect in my GTK code for displaying context menus. After creating a menu with a number of menu items, I use gtk_menu_popup() to display the menu. This function takes a function pointer of type GtkMenuPositionFunc which lets me position the menu. I don't really do anything here except tell GTK to keep current position but push the menu in if part of the menu is outside the monitor (using the fourth argument to the function). My problem is that when GTK pushes the menu in, the absolute position of the menu items does not change. Hence their scroll position changes resulting in scroll bars in the menu. I want the relative position of the menu items w.r.t the menu to remain fixed. Is there any way I can do that? The GTK documentation does warn about this problem, but does not say anything about how to fix it. There is the link to it for reference:
http://library.gnome.org/devel/gtk/unstable/GtkMenu.html#GtkMenuPositionFunc
EDIT: I would have liked to include some code, but the logic is too scattered for that.
You don't need to provide a positioning function if you just want the default behavior. The default behavior is to keep the current position but make sure the menu fits on the monitor, so you can just pass NULL as the positioning function.
You can also take a look at how the default positioning function is written: http://git.gnome.org/browse/gtk+/tree/gtk/gtkmenu.c, gtk_menu_position() currently at line 4288.
PS. If your logic is too scattered to post a code sample, then you should consider cleaning it up.
I was not able to find any way to readjust the scroll-offset of menu items once the menu is pushed in. So, the workaround I used was to avoid having GTK push the menu in vertically. Hence, the original request was to create the menu at position (x,y) but resulted in length L of the menu going out of the screen, I reposition the menu at (x,y-L) in my position function. Similarly, if y<0 I change set it to (x,0). I still tell GTK to push in any menu that goes outside the screen to take care of menus going over the left and right margins.

Resources