How to highlight a line in a text stream and position the cursor at the end.
I would like to select a line in a text control data stream, highlight the text, and place the cursor at the end of the line so that the text control can be edited at that point.
Depends on what you mean by "highlight". If you mean highlight in the sense of when you use the mouse to select text, then you can't do that and then place the cursor at the end, since that would effectively "unhighlight" the text. You need to use a different kind of "highlight", like turning the text bold or something. This KB article talks about highlighting particular characters: How Do I Highlight Particular Characters in a String Control?
See attached for simple example. Modify as needed.
Attachments:
Text Select.vi 19 KB
Similar Messages
-
I am currently implementing an IDE. I try to highlight entire line(not only text but also following blank field) when users set a breakpoint on that line.
Using Highlighter.addhighlight(start, end, HighlightPainter) only allow me to highlight the text part in the line. I haven't figure out how to do that.
Any helps are appreciated.one way to highlight a full line or draw a breakpoint
symbol on a particular is to create a custom highlight
painter and override the paint method. If you want to
highlight the full line then use the width from the
JTextArea and only the y coordinate and height from
the view coordinates.
If you would like a breakpoint symbol and a particular
line then just put a drawImage call in the paint method
which draws an icon on that line
I've included some code for custom painter for both
highlighting a full line and rendering a breakpoint
icon.
private class SingleLineHighlighterPainter extends DefaultHighlighter.DefaultHighlightPainter {
public SingleLineHighlighterPainter( Color color )
{ super( color ); }
* Paints a highlight over a single line.
* just uses the first point a work around only
* @param g the graphics context
* @param offs0 the starting model offset >= 0
* @param offs1 the ending model offset >= offs1
* @param bounds the bounding box for the highlight
* @param c the editor
public void paint(Graphics g, int offs0, int offs1, Shape bounds, JTextComponent c) {
Rectangle alloc = bounds.getBounds();
Rectangle area = c.getBounds();
try {
// --- determine locations ---
TextUI mapper = c.getUI();
Rectangle p0 = mapper.modelToView(c, offs0);
// --- render ---
Color color = getColor();
if (color == null) {
g.setColor(c.getSelectionColor());
else {
g.setColor(color);
// render using just the y coordinates and height from the initial point
g.fillRect(0, p0.y, alloc.width, p0.height);
catch (BadLocationException e) {
// can't render
private class BreakpointPainter extends DefaultHighlighter.DefaultHighlightPainter {
public BreakpointPainter()
{ super( Color.green ); }
* Paints a breakpoint image
* just uses the first point a work around only
* @param g the graphics context
* @param offs0 the starting model offset >= 0
* @param offs1 the ending model offset >= offs1
* @param bounds the bounding box for the highlight
* @param c the editor
public void paint(Graphics g, int offs0, int offs1, Shape bounds, JTextComponent c) {
Rectangle alloc = bounds.getBounds();
Rectangle area = c.getBounds();
try {
// --- determine locations ---
TextUI mapper = c.getUI();
Rectangle p0 = mapper.modelToView(c, offs0);
Image im = ( (ImageIcon) Icons.stopSignIcon ).getImage();
// render using just the y coordinates and height from the initial point
g.drawImage( im,0,p0.y+2,null );
catch (BadLocationException e) {
// can't render
to use these do the following
DefaultHighlighter dh = new DefaultHighlighter();
dh.setDrawsLayeredHighlights( false );
SingleLineHighlighterPainter dhp = new SingleLineHighlighterPainter(Color.green);
BreakpointPainter bpp = new BreakpointPainter();
buff.setHighlighter(dh);
try {
dh.addHighlight(25, 30, dhp); // single line highlighter here
dh.addHighlight(60, 60, bpp); // add breakpoint highlighter here
dh.addHighlight(120,120,bpp); // add breakpoint highlighter here
catch (javax.swing.text.BadLocationException jst) { };
buff.setMargin( new Insets( 0,20,0,0 ) );
where numbers used with the addHighlight method are
the location within the model. In this case the
addHighlight( 25,30, dhp ) will highlight the line with
a view location corresponding to position 25 in
the model. So just need to specify any model location
on the line you want to highlight.
Setting breakpoints is the same just need one model
position on the line where you want the image to be
drawn.
Hope that's clear.
Also helps to look at the source code for
DefaultHighlighter.java.
eric
[email protected] -
how do you get your ipod touch to make a noise when people text you and to pop up on the screen my friend did something to her ipod to do this but i dont know how please help!!!!!!!!!!!!!!!!!!!!!!!!!!! its like she updated it but i already tried it!!!!!!i am very confused and want my ipod touch 4g like that please help thxns:)
Go to Settings>Notifications and turn alerts/sounds on for the app(s) in question. Not all apps have all options.
-
How to position the cursor at the end of the text with EDIT_TEXT?
Hello, it wanted to ask to them if somebody could make work the module of function EDIT_TEXT so that it positions the cursor at the end of the text that is visualizing in the text editor. In the documentation it says that passing a ' X' to him in the field scrollend of the parameter Control is obtained that operation. Nevertheless, I did this and the cursor continues appearing at the beginning of the text that visualizes.
Somebody could help me please?
Regards,
Gabriel
PD: The code that I use is the following one:
FORM f_ingresar_comentarios.
DATA: l_action,
l_result LIKE itcer,
l_pedido LIKE thead-tdname,
li_coment_save LIKE i_comentarios OCCURS 0,
li_coment_aux LIKE i_comentarios OCCURS 0 WITH HEADER LINE,
l_lines TYPE i,
l_lines_save TYPE i,
l_lines_insert TYPE i,
l_index TYPE i,
l_index_aux TYPE i,
l_insert,
lwa_control LIKE itced.
CLEAR: l_action.
CLEAR i_comentarios.
REFRESH: i_comentarios,
li_coment_save,
li_coment_aux.
l_pedido = v_pedido.
Leemos el texto si es que existe
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = v_id_text
language = sy-langu
name = l_pedido
object = c_ekko
IMPORTING
header = wa_cabecera
TABLES
lines = i_comentarios "Lineas de texto leídas
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
IF sy-subrc <> 0.
Armamos la cabecera por primer comentario para el pedido
CLEAR wa_cabecera.
wa_cabecera-tdobject = c_ekko. "Objeto en tabla TTXID
wa_cabecera-tdname = v_pedido. "Nro de pedido
wa_cabecera-tdid = v_id_text. "ID en tabla TTXID
wa_cabecera-tdspras = sy-langu. "Lenguaje
wa_cabecera-tdlinesize = 70.
ENDIF.
Salva comentarios originales
li_coment_save[] = i_comentarios[].
lwa_control-scrollend = c_x. " c_x = 'X'
Abre el editor de texto
CALL FUNCTION 'EDIT_TEXT'
EXPORTING
header = wa_cabecera
save = space
control = lwa_control
IMPORTING
newheader = wa_cabecera
function = l_action
RESULT = l_result
TABLES
lines = i_comentarios
EXCEPTIONS
object = 1
id = 2
language = 3
name = 4
linesize = 5.
Si cambio los comentarios, actualiza comentarios
CASE l_action.
WHEN c_unchanged.
WHEN c_delete.
WHEN c_update OR
c_insert.
Obtiene cantidad de lineas de comentarios originales y modificados
DESCRIBE TABLE li_coment_save LINES l_lines_save.
DESCRIBE TABLE i_comentarios LINES l_lines.
Si se insertaron lineas...
IF l_lines > l_lines_save.
Calcula cantidad de lineas a insertar para luego calcular valor de
indice a partir del cual insertar los nuevos comentarios
l_lines_insert = l_lines - l_lines_save.
l_index = ( l_lines - l_lines_insert ) + 1.
Controla que al menos una de las lineas insertadas sea diferente de
blanco
l_index_aux = l_lines.
l_insert = c_n.
DO l_lines_insert TIMES.
READ TABLE i_comentarios INDEX l_index_aux.
IF sy-subrc = 0 AND
i_comentarios-tdline <> space.
l_insert = c_s.
EXIT.
ENDIF.
l_index_aux = l_index_aux - 1.
ENDDO.
IF l_insert = c_s.
Carga comentarios originales y agrega lineas insertadas
li_coment_aux[] = li_coment_save[].
APPEND LINES OF i_comentarios
FROM l_index
TO l_lines
TO li_coment_aux.
Setea variable para indicar actualizacion de comentarios.
v_comentario = 'S'.
Agrega usuario y fecha del comentario
CONCATENATE sy-uname
sy-datum
INTO li_coment_aux-tdline
SEPARATED BY space.
li_coment_aux-tdformat = '*'.
APPEND li_coment_aux.
Grabamos el texto
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
client = sy-mandt
header = wa_cabecera
savemode_direct = c_x
IMPORTING
newheader = wa_cabecera
TABLES
lines = li_coment_aux
EXCEPTIONS
id = 1
language = 2
name = 3
object = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDIF.
ENDCASE.
ENDFORM. " f_ingresar_comentarios
In addition, I made another program simpler that it uses the same functions and also have the same problem:
*& Report Y_GVA_TEXT *
REPORT y_gva_text .
DATA: wa_cabecera LIKE thead,
i_comentarios LIKE tline OCCURS 0 WITH HEADER LINE.
DATA: l_action,
v_comentario,
l_result LIKE itcer,
v_pedido LIKE thead-tdname VALUE '3',
l_pedido LIKE thead-tdname,
c_a05 LIKE thead-tdid VALUE 'A05',
c_ekko LIKE stxh-tdobject VALUE 'EKKO',
l_lines LIKE sy-tabix,
lwa_control LIKE itced.
CONSTANTS: c_x VALUE 'X',
update VALUE 'U', "Langtext verändert
insert VALUE 'I', "Langtext eingefügt
delete VALUE 'D', "Langtext gelöscht
modify VALUE 'M', "Kein Langtext, Inlinezeile veränd.
unchanged VALUE ' '.
CLEAR: l_action.
CLEAR i_comentarios.
REFRESH i_comentarios.
Leemos el texto si es que existe
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = c_a05
language = sy-langu
name = v_pedido
object = c_ekko
IMPORTING
header = wa_cabecera
TABLES
lines = i_comentarios "Lineas de texto leídas
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
Armamos las cabecera para mostrar los comentarios
CLEAR wa_cabecera.
wa_cabecera-tdobject = c_ekko. "Objeto en tabla TTXID
wa_cabecera-tdname = v_pedido. "Nro de pedido
wa_cabecera-tdid = c_a05. "ID en tabla TTXID
wa_cabecera-tdspras = sy-langu. "Lenguaje
wa_cabecera-tdlinesize = 70.
ENDIF.
lwa_control-noendlines = c_x.
lwa_control-scrollend = c_x.
Abre el editor de texto
CALL FUNCTION 'EDIT_TEXT'
EXPORTING
header = wa_cabecera
save = space
control = lwa_control
IMPORTING
newheader = wa_cabecera
function = l_action
RESULT = l_result
TABLES
lines = i_comentarios
EXCEPTIONS
object = 1
id = 2
language = 3
name = 4
linesize = 5.
Si cambio los comentarios, actualiza comentarios
CASE l_action.
WHEN unchanged.
WHEN delete.
WHEN update OR
insert.
Agrega usuario y fecha del comentario
CONCATENATE sy-uname
sy-datum
INTO i_comentarios-tdline
SEPARATED BY space.
i_comentarios-tdformat = '*'.
APPEND i_comentarios.
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
header = wa_cabecera
IMPORTING
newheader = wa_cabecera
TABLES
lines = i_comentarios.
ENDCASE.Murugesh,
I believe that you have mis-read Gabriel's problem.
Gabriel,
The cursor is not positioning at the base of the editor as you have cited.
In order to get this functionality to work, you must set the LINE_EDITOR import paramter to 'X'.
data: hdr like THEAD.
data: l_itced like itced.
hdr-tdobject = 'VBBP'.
hdr-tdname = '4000029521000030'.
hdr-tdid = 'Z005'.
hdr-tdspras = 'E'.
hdr-TDLINESIZE = '100'.
hdr-TDTXTLINES = '3'.
l_itced-SCROLLEND = 'X'.
CALL FUNCTION 'EDIT_TEXT'
EXPORTING
DISPLAY = ' '
EDITOR_TITLE = ' '
HEADER = hdr
PAGE = ' '
WINDOW = ' '
SAVE = 'X'
LINE_EDITOR = 'X' " here !!!
CONTROL = l_itced
PROGRAM = ' '
LOCAL_CAT = ' '
IMPORTING
FUNCTION =
NEWHEADER =
RESULT =
TABLES
LINES = lines
EXCEPTIONS
ID = 1
LANGUAGE = 2
LINESIZE = 3
NAME = 4
OBJECT = 5
TEXTFORMAT = 6
COMMUNICATION = 7
OTHERS = 8
Don't forget those points !! -
How do i copy a thread in text messages and copy into a note pad app?
how do i copy a thread in text messages and copy into a note pad app?
Tap and hold a bubble, and select More. Put a checkmark beside each bubble you want to copy, then hit the arrow at bottom right. This will open a new message with the copied text in the text entry box. You can copy all of this and paste into Notes, but you lose who it came from unless you edit that in yourself.
You can also take screenshots of each window of text bubbles. -
Hi, While writing an email online using Firefox 3.6.3, I was using one of the "CTRL+left or right arrow" to move the cursor along the text. I must have pressed some other key because the display has become huge - and I can't scroll vertically or horizontally, which makes using the Mail pages of Hotmail impossible. I have since logged in using MSFT Explorer and it works fine. This problem occurs only on the Mail page of Hotmail Live not on the home page or others.
Could you please let me know if this is a problem with Firefox, or if you have any advice on how to reset the appearance of Hotmail in Firefox?
== This happened ==
Just once or twice
== While I was compiling an email in Hotmail LiveWow, lightning fast and absolutely right!
Thank you so much! -
Setting the cursor at the end of a text item Forms 10g
Is there a way in 10g forms to set the cursor at the end of the text item without highlighting the text.
I have a text item field when I query it and tab to the field, it highlights the whole text inside the block item. Users sometimes type without thinking so, we made it set the cursor at the end.
I know in 6i forms there was a client package (d2kwutil) that accomplished this and if I have too, I'll use it via the WebUtil. I just was not sure if there was anything in 10g forms that accomplished the same task.
Any help is appreciated.
ChrisHello,
You can also use the good old win_api_shell.sendkeys() d2kwutil function, that works also fine with Web versions.
For instance, in a When-New-Item-Instance trigger:
win_api_shell.sendkeys(get_window_property('WINDOW1',window_handle),'{End}',TRUE); Francois -
How can I replace the cursor in the below query?
I have this below query which calls a stored procedure that takes only 1 item's attributes at a time. But because of performance problems we are
required to remove the cursor. How can I replace the below cursor logic with set operations or CTE? Please advice.
DECLARE db_cursor_ava CURSOR
FOR
SELECT t.[agent-id],
t.[start-date],
t.[end-date],
t.[monitor-days],
t.[monitor-start],
t.[monitor-end],
t.[timezone-offset]
FROM @tmpAgentPeriodTimeRange t
OPEN db_cursor_ava
FETCH NEXT FROM db_cursor_ava INTO @agentID_ava,
@stDateTime_ava,
@endDateTime_ava,
@monDays_ava,
@monSt_ava,
@monEnd_ava,
@offset_ava
WHILE @@FETCH_STATUS = 0
BEGIN
DELETE
FROM @tmpMonitorPeriod
DELETE
FROM @tmpFinalResult
SET @runID = 1
IF(@endDateTime_ava>DATEADD(MI,@offset_ava, GETUTCDATE()))
BEGIN
SET @endDateTime_ava=DATEADD(MI,@offset_ava, GETUTCDATE())
END
INSERT INTO @tmpMonitorPeriod
EXEC core.usp_GetMonitoringPeriod
@startDate = @stDateTime_ava,
@endDate = @endDateTime_ava,
@monitoringDays = @monDays_ava,
@monitoringStart = @monSt_ava,
@monitoringEnd = @monEnd_ava
SELECT @maxID = MAX(tm.id)
FROM @tmpMonitorPeriod tm
FETCH NEXT FROM db_cursor_ava INTO @agentID_ava,
@stDateTime_ava,
@endDateTime_ava,
@monDays_ava,
@monSt_ava,
@monEnd_ava,
@offset_ava
END
CLOSE db_cursor_ava
DEALLOCATE db_cursor_ava
mayooran99You've been down this path before - and the response is exactly the same.
how to replace cursor logic
And I'll suggest that you post the entire code - since you repeatedly delete 2 table variables but only populate one. The setting of @maxID also seems to have no purpose. And perhaps the issue here isn't the cursor but the general approach. Who knows
- but it appears you may have prematurely assumed that the cursor is the problem. -
I'm told there is a virus associated with Adobe Reader. How can I tell if my machine is effected and if so what is the cure. I'm running OS X10.6.8 on an iMac with safari 5.1.5
There are no viruses currently affecting the Mac but there is something called Flashback which is malware that has been doing the rounds and affected many Mac users. Apple have released some updates to Java that should remove it and improve protection. Run Software Update to see if there is anything for downloading.
A few precautions that can help prevent your Mac becoming infected:
If you use Flash only download it directly from Adobe.
In all web browsers disable Java (but do leave Javascript on as that's something else).
In all web browsers make sure downloaded files aren't set to automatically open after downloading.
Consider disabling Java completely (launch Java Preferences in the Utilities folder and disable it - you'll likely rarely, if ever need it. If you do just turn it on and off again when your done).
You can also check out this link:
http://lifehacker.com/5900434/how-to-find-out-if-your-mac-was-infected-by-the-fl ashback-trojan-in-one-click -
How to programmatically move the cursor to the "To" field of a new AppointmentItem?
I need to move the cursor to the "To" field of all new AppointmentItems which are created through my Outlook Addin. How I can achieve this?
Thanks in advance.
Thanks PrasadHello Prasad,
The Outlook object model doesn't provide anything for that. You need to use Windows API functions or use
Accessibility API to set the cursor programmatically. -
Safari status bar disappears. I have tried clicking on show status bar, under the View tab and it will only appear when I move the cursor to the top of the screen. I can not minimize the open page, only full screen or close the browser. Any idea how the rectify this issue?
One enters and exits full-screen with control+command+F keys. This is on the View menu in Safari. Optionally, the green traffic light in your browser title bar, if you roll over it, has the full-screen control it it. While in full-screen mode with Safari, moving your mouse pointer virtually up, and off-screen reveals the Safari title bar again, and you can click the green traffic light to exit full-screen mode.
You can hide/show the status bar by simply typing command+/. This too, is on the Safari View menu. and in 10.10.1 — it works reliably for me. -
After transition on Windows 7 there was a problem with Firefox. At work with the text at allocation by the cursor of the big fragment of page it is necessary to shift all time it downwards, "against the stop", but the page automatically does not start to rise upwards as it was earlier and as occurs in other browsers. It is necessary to press other hand a key "downwards" that is the extremely inconvenient. Reinstallation on earlier version (8.0) earlier irreproachably working, has given nothing. I ask the help
You need to enable the Add-ons bar (Firefox > Options or View > Toolbars; Ctrl+/) or the Find bar (Ctrl+F) to make Firefox scroll the page while selecting text.
-
How i can fixup the cursor in the center of plot at any time?
i need the cursor show the data of the points in plot,but i found after the plot zoomin,the cursor can not show .how i can fixeup the cursor at any time?
thanks a lot.Hi Longsan,
So I tried to reproduce the issue you were seeing and I believe I know what is going on. If you zoomin and the max and min of the axes are smaller than the cursor position, the cursor will no longer be in the viewing area of the graph. Therefore, you would want to reposition the cursor after you zoom in. For example, in Visual Basic you could use the command
CWGraph1.Cursors(1).XPosition to change the position. I thiss out and it seems to work correctly. Let me know if try this and you are still having trouble.
Thanks,
Caroline
National Intruments
Thanks,
Caroline Tipton
Data Management Product Manager
National Instruments -
Hi , at Launchpad when I move the cursor up the screen starts to thimble. Any idea how to fix it. thanks Jacob
HI Jacob, Did you ever solve your problem with Launchpad? I am having the same problem now.
-
at Launchpad when I move the cursor up the screen starts to tremble. any idea how to fix it ? Jacob
HI Jacob, Did you ever solve your problem with Launchpad? I am having the same problem now.
Maybe you are looking for
-
Hi I am testing the web service which I have developed from the Sender agreement in PI 7.1 version by using the xml SPY I received the error as HTTP error Could not POST file Here is the parameters, please give an idea if i need to change any param
-
I wanted to know explain my problem down package cc2014 where I put the serial number of the problem that I have is that when you open the program asks me start of session in which he put it and go but back inside and it drives me to request the star
-
How can I find movies created in past versions of iMovie? They are still on you tube but I want the original higher quality versions and I can't find them anymore.
-
Thread: Cannot connect to auxiliary instance posted by William Wong
I am experiencing the same issue and I am able to get the suggestion to work connecting to both the target and auxiliary databases on the auxiliary server, but I don't know where to go from there. Do I go back to the target server and continue from t
-
DBMS_DATAPUMP import into another database instance
Hi there, i have a quick question as i didn't find an answer in my oracle documentations... I use a PL/SQL program in a Oracle Application Express (APEX) application to import a dumpfile via the dbms_datapump API. It`s no problem to import it into th