Cursor over dynamic textfield fails to track - cursor

I am having a problem and i am not sure what to do although the answer must be obvious..
I have a movieclip and inside the movieclip a dynamic text field.
I want to move the moveclip when my cursor is inside it but the problem is the area of the textfield isn't recognized as part of the movieclip although its in it. This results the movieclip to stop when the cursor touches the textfield area. Any suggestions? :(

Related

Show Gtk.Popover at cursor of Gtk.Entry

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.

Access a component inside a Tab component

I'm new using Codename One. I'm doing an app which have a Form, that has a Tab component with 14 tabs inside, every tab has a gridlayout with 42 buttons, and I want to change a property in one button.
The problem is that I don't know how to reach that button.
tabG.getContentPane().components.get(index)
tabG is the tab component, and I can reach the tab that I need, but after that I don't know how to reach the button index I want to change.
I tried
tabG.getContentPane().components.get(index).components.get(indexbutton)
But even can't compile this code.
I'll apprecciate any help.
When you create the tab you need to prepare information to find the component later. E.g. if all tabs derive from the same class then just do something like:
MyBaseContainer cnt = (MyBaseContainer)tabs.getTabComponentAt(index);
Button theButtonINeed cnt.getMyImportantButton();
If this is more complicated you can use setName() or putClientProperty to prepare hints for you during form construction.

Swift: Add buttons to array without creating Outlet?

I'm a novice at Swift programming.
I've created an app with multiple identical buttons. I created one button with an action and then copied this button multiple times so that it uses the same action.
When one of the buttons are pressed, the image for the button changes ('image2' from 'image1'), and the button is disabled.
All good and fine so far.
I've then tried to create a reset button, where the buttons that have been pressed are enabled again, and the image for them changed back to 'image1'.
I did this by creating a collection outlet for a single button and then adding some of the other ones, one-by-one.
#IBOutlet var mybuttons: [UIButton]!
As I understand this creates an array with the buttons.
I then go over this array and update the image and enable the button, with a loop:
for myBubble in self.bubble
Now, my question is: Instead of having to drag each and every button to the outlet collection, would it be possible to add them to an array when they are pressed, and then run over that array instead?
I tried to create an array with
var mybuttons: [UIButton]!
and then use append(sender) when a button was pressed, but this gave a fatal error.
As mentioned I could solve this by simply adding all to an outlet collection but was wondering if there was a more elegant way to do it, since there are quite a lot of buttons.
As mentioned I'm a novice at this.
Thanks in advance.
Best regards,
Thomas
You have just declared your button array but not initialized it:
var myButtons = [UIButton]()
This way you declare and initialize an empty array and you can start to append your objects to it.

Can't properly force a component on-screen with scrollComponentToVisible

On a given form, we replace one component with another.
The original component is a series of TextFields, and the new form is some informational text and a button. We hide the first one, and show the second one (the UI designer has both Containers within the form).
I tried using scrollRectToVisible with various values but it didn't seem to make any difference with the scrolling.
continueButtonContainer.setHidden(false);
f.forceRevalidate();
Button continueButton =
(Button)StateMachine.GetInstance().findByName("ButtonContinue", f);
f.scrollComponentToVisible(continueButtonContainer);
f.scrollComponentToVisible(continueButton);
I'm expecting the continue button to be near the top of the screen.
If the screen was scrolled before displaying the continue button, the button ends up right at the bottom of the screen (it was below the bottom of the screen before I put in the scrollComponentToVisible line(s).
After the user scrolls the screen, the button goes up to where it needs to be, and stays there.
If the screen is not scrolled, the button appears where it should be.
I know I can probably add some invisible containers underneath the button and force them onto the screen, but I would rather have a slightly more robust solution.
There are a few issues with this. First you are using forceRevalidate which should be used in very rare cases.
Second it seems that you are invoking this on a Form, this is a bit misleading. While it seems that:
f.add(myCmp);
Adds a component to the form it is really a synonym to:
f.getContentPane().add(myCmp);
That's important because you need to invoke the scrollComponentToVisible on the scrollable container which will actually do the work and ideally be the direct parent of said component. I'm assuming it's the content pane in your case but it depends on layout etc.
The last part is letting the layout do its job. If you are invoking this before the form is showing this might not work. Notice that doing it after a call to show is meaningless as the form might take time with transitions. You can use a show listener or override the laidOut callback method to perform things like this.

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().

Resources