UIWebView paragraph selection style - objective-c

as you can see in the first picture ,i'm using the UIWebview in my app.
But when i drag the second handle to the next paragraph , the selection become a rectangle box , i can only select the whole paragraph , how can i keep it just like the first picture?

from reading Using Copy, Cut and Paste Operations, you can see that iOS has implemented the UI selection for UIWebView, UITextView and UITextField for you, and thus what you are seeing is simply how selection works in these UI objects.
(and it is thus: so long as the user is within the bounds of a paragraph, then the user will be able to select a portion of the text in the paragraph as you have demonstrated in your first view; and if the user's fingers run beyond the edges of the paragraph, the underlying UI code showing the selected area will attempt to select the smallest subset of items it can select, with entire paragraphs being considered an atomic unit at this level.)
given that the documentation referenced above describes only how to invoke the various cut/copy/paste/select actions when invoked from a menu (with some control over what appears in the UIMenuController's menu, and some control over what you can do with the cut/copied selection in a UIPasteboard), there doesn't seem to be a handy way to direct how the UI responds to the user controlling the edge of the selection. even going so far as extending UIWebView might give you the ability to capture the touch events necessary, but you wouldn't be able to direct the resulting drawing of the selection through documented API of UIWebView.
and so, without mucking with non-public API, it's a little hard to imagine how you could have a more precise fine-grain control over selecting text spanning paragraphs unless you go to the length of implementing your own class to capture the touch-events necessary to control he selection and then process the events to draw the selection around the edges that you prefer. in other words, you'd sort of have to re-invent UIWebView and all that it does, with the exception of your special code for selections spanning textual paragraphs.
sorry.

Related

How to disable Sap Business One form's default resizing behavior?

I'm developing the custom UI layout system for our custom SBO forms. I.e. catching form's resize event and arranging the controls according to our specific layout logic. The problem is that, apparently, SBO tries to arrange controls according to its (clunky and primitive) logic on every form resize first! My code handling the resize event and rearranging the items works, but there is a noticeable performance delay, as items are essentially re-positioned twice on each form resize - once by SBO itself, and then by my code.
Is there any way to stop SBO arranging controls on our custom forms during resize, so that they will be positioned only once by my code (in the resize event handler)?
This page by Boyum IT helps to explain what the resizing rules are.
There's additional information on this page
To summarize those pages, every form is split into 4 quadrants, which are effectively pinned to the corners of the form that they belong to.
That means that as you resize the form, these quadrants separate from each other, leaving large sections of space between them.
I don't believe that there's an easy way to prevent this behavior out of the box, but you can manually override it using the B1 UI API, by setting the LinkTo property of the Items to match the ID of one of the Items in the top left quadrant, which causes the given item to move with the same behavior as that of the item specified in LinkTo.

What class does Qt designer use to edit the properties of UI elements?

At the moment I'm writing a tool to extract parts of frames of mp4-video files. You draw rectangles on the video and the tool extracts .png-images at regular intervals. Now I want to give the user the ability to edit the properties of individual rectangles they have drawn on the video (exact position, frequency of frame extraction, time frame, etc.). I like the approach that QtDesigner takes for editing ui elements. You can see what I mean in this screenshot i found on the internet
The yellow and green table contains name value pairs for the different properties of the selected ui element. The table is devided into section depending on what class the property was inherented from. In the Screenshot the green part is inherented from MarbleWidget. The yellow part is inherented form a different class. I want each division to refer to a different rectangle and the color to match the colour the rectangle is drawn in on the screen.
I've tried using QTreeView, QTableView, QToolBox and QTableWidget but none of these - to my knowledge - offer putting QWidgets in the "value" part of the table. In the screenshot you can see tick boxes for example. In my case I would want to use a range slider. Does anyone know what class is used to Implement this table?
I think you'll find it difficult to use the designer classes in a normal application.
See qtpropertybrowser for a properties editor.
See setIndexWidget for a static widget. As it says, use QItemDelegate for dynamic widgets. Note that the specific item subclasses have their own methods like QTableWidget.setCellWidget.

iOS Longpress to select text

I am building a simple table based search app. The user can ofcourse search through keyboard. But I also want to have another mode of search.
Say a user longpress on a UILabel then based on where the press is happening, that word should get selected & search should happen (no keyboard) on that word.
I know how to detect longpress events but does anyone know how to copy, detect & access the exact term where the longpress has occurred?
UPDATE: I am aware that I can get the object where longpress occurred from which I can get the content of the label text. But I need the exact word on top of which the finger was placed.
Nothing easy comes to mind for UILabel or UITextView. If you're wiling to lay the text out yourself with Core Text, then you can pretty easily find words near the touch. The trouble with that is you'd lose the existing selection features of UILabel and have to reimplement them (or do "shadow layout" in Core Text hoping things will lay out identically in the UILabel... slowly descending into madness here.)
Rather than going down this rabbit hole, I'd recommend using the standard text selection mechanism and add "search" to the menu.
Just put a UILongPressGestureRecognizer on your label then when the gesture recognizer fires you can access which object it came from and read the label value from there.
myLongPressRecognizer.view

What type of annotation (or other object) to use?

I'd like to take an existing PDF and add semi-transparent rectangles on top of the pages, at pre-defined locations. When the user moves the mouse over the rectangle, it should change color and/or transparency. I should be able to define different colors (including transparency) for both states. Clicking on it executes some action that I define (such as going to another page, or a website).
I understand that this can be done with annotations, but I'm having trouble figuring out which type of annotation would be best suited. They also don't seem to handle transparency very well. Of course, I'm open to using something other than annotations, if need be...
1) That would have to be annotations. If it's clickable-and-does-something, it's an annotation. It could be an annotation on top of some page content, but an annotation must be involved.
2) You can set the appearance of a button to be arbitrary PDF content, including "normal" and "mouse-over" appearances. Note that these appearances aren't available through the Acrobat UI, but can be accessed programmatically from your API of choice at the object level. All appearance dictionaries have 3 different states: "N"ormal, "R"ollover, and "D"own.
To be honest, I've never tried setting a form field's rollover (or down for that matter) appearance, so I'm not sure how well that will work, but the Theory is sound.
What's the difference between theory and practice? In theory, there's no difference between theory and practice. Ouch.
You didn't specify a programming language/os/anything, so it's not possible to give more detail.
Use a button with an ICON appearance and a transparent background. The icon is an arbitrary PDF content stream with resources. Within it, you can set transparency just like you would as part of a page content stream. In fact, the only way the acrobat gui lets you pick an icon is to select a page from an existing PDF document.
Alternatively you might also be able to set the widget's /DA to use transparency with an extended graphic state resource that you'd add to the Acroform's DR dictionary. I haven't tried that myself.

Draw Lines on gtk.TextView

I'm trying to show the "selection" of a certain sub-string in a
gtk.TextView by drawing a border around the word. The only way to mark
text in a TextView that I've found so far is by placing TextTags with
modified properties. This does not seem to offer a way to draw a border,
though, DOES GTK SUPPORT THIS OR IS THIS A PROBLEM WITH ONLT PYGTK
I figured out how to draw on a text view !!!
To begin with lets assume the reference to your gtk.TextView is in a variable called viewer, Inside one of ur classes
Also the draw function has to be called with an event called expose-event else the drawings will be refreshed and will not stay on the screen
The next part is the gtk.TextView consists of 7 types of gtk.gdk.windows on which u can draw
gtk.TEXT_WINDOW_WIDGET
gtk.TEXT_WINDOW_TEXT
gtk.TEXT_WINDOW_LEFT - not displayed by default
gtk.TEXT_WINDOW_RIGHT - not displayed by default
gtk.TEXT_WINDOW_TOP - not displayed by default
gtk.TEXT_WINDOW_BOTTOM
gtk.TEXT_WINDOW_PRIVATE
For the drawing to appear on gtk.TextView We have to draw on gtk.TEXT_WINDOW_TEXT
An Example Code is as shown Below
if(viewer!=None):
viewer.connect("expose-event", expose_view)
self.drawable=viewer.get_window(gtk.TEXT_WINDOW_TEXT)
def expose_view(self,window,event):
if(self.drawable!=None):
self.drawable.draw_line(self.drawable.new_gc(),1,1,30,30)
# (1,1) and (30,30) are the coordinates and u can give the values accordingly
In a gtk.TextBuffer tags are used to set one or more pre-defined text attributes. Without subclassing, this is limited to the properties of a gtk.TextTag, and doesn't include anything akin to a border or outline property. There is no difference between PyGTK and plain GTK+ in this regard.
While somewhat hacky, the easiest way to do what you want to do is to connect to the expose-event of your gtk.TextView, get the coordinates of your string and draw on event.window, which is the gdk.Window of the event provided in the expose callback.
(Note that you don't have to get and store the gtk.TEXT_WINDOW_TEXT window, you just need to check what window the expose event is for in the callback, probably ignoring the expose if it's not for the text window.)
Instead, you could presumably subclass one or more of TextBuffer/TextView/TextTag to add a border tag, but whether it's reasonable to do so is another question.