Re: Forms 4.5 multiple row selection?
Date: 1997/04/20
Message-ID: <335AB72E.1DD1_at_postoffice.worldnet.att.net>
Here is the code for multi-select logic that we created. This allows the user to use Control and Shift click as well as ALT-CLICK. ALT-CLICK allows the user to select the 1st record, then hold the control key and select the 3rd, then hold the ALT key and select the 6th. This will select records 3-6, leaving record 1 selected.
Joe Strano
Dulcian, Inc.
/*
|| This package is used by the associated and available events blocks.
|| These procedures handle the selection of multiple records using
|| Windows standards commands.
|| Joe Strano
|| Dulcian, Inc.
|| 8 Feb 97
*/
PACKAGE BODY select_logic IS
/*
|| Sets the current row the proper color.
|| Joe Strano
|| Dulcian, Inc.
|| 8 Feb 97
*/
procedure color_row(cur_block varchar2) is
temp_list2 varchar2(300);
cur_item varchar2(100);
vis_attribute varchar2(100);
status varchar2(100);
begin
temp_list2 := name_in(cur_block||'_header.select_list');
if name_in(cur_block||'.SELECTED') = 'YES' then
vis_attribute := 'NORMAL';
copy(null,cur_block||'.SELECTED');
status :=
listx.del_from_list(temp_list2,get_block_property(CUR_BLOCK,CURRENT_RECORD));
else
vis_attribute := 'SELECTED';
copy('YES',cur_block||'.SELECTED');
listx.add_to_list(temp_list2,get_block_property(cur_block,CURRENT_RECORD));
end if;
cur_item := get_block_property(cur_block,FIRST_ITEM);
/* Set all fields in the block the proper color */ While cur_item IS NOT NULL Loop
cur_item := cur_block || '.' || cur_item;
display_item(cur_item,vis_attribute);
cur_item := Get_Item_property(cur_item,NEXTITEM);
End Loop;
copy(temp_list2,cur_block||'_header.select_list');
end; --color row
/*
|| Erases all selections from the list.
|| Joe Strano
|| Dulcian Inc.
|| 8 Feb 97
*/
procedure wipe_list (in_list varchar2,cur_block varchar2) is
begin
for counter in 1..listx.counts(in_list) loop
go_record(listx.peel(in_list,counter)); color_row(cur_block);
end loop;
end;
/*
|| Main block of code for mutli-select logic.
|| Joe Strano
|| Dulcian, Inc.
|| 8 Feb 97
*/
PROCEDURE SELECTED IS
CUR_ITEM VARCHAR2(80); CUR_BLOCK VARCHAR2(80) := :System.Cursor_Block; sel_id item; vis_attribute varchar2(80);
selected_value varchar2(10);
status varchar2(200);
selec_list varchar2(300);
temp_list varchar2(300);
temp_list3 varchar2(300);
cur_rec number;
anchor_rec number :=1;
tempchar varchar2(10);
BEGIN /* If the current block has a selected field, then use this logic */ sel_id := find_item(cur_block||'.SELECTED'); if not id_null(sel_id) then
/* If user held down the control button when they clicked */ if :system.mouse_button_shift_state = 'Ctrl+' then
color_row(cur_block);
/* The user just clicked */
elsif :system.mouse_button_shift_state is null then
cur_rec := get_block_property(cur_block,CURRENT_RECORD); temp_list := name_in(cur_block||'_header.select_list'); selected_value := name_in(cur_block||'.SELECTED'); --temp hold seleted value wipe_list(temp_list,cur_block); go_record(cur_rec); if selected_value is null then color_row(cur_block); --select row if it wasn't selected before end if;
/* The user held Shift when they clicked */ elsif :system.mouse_button_shift_state = 'Shift+' then
cur_rec := get_block_property(cur_block,CURRENT_RECORD); temp_list := name_in(cur_block||'_header.select_list'); wipe_list(temp_list,cur_block); anchor_rec := listx.pop_lifo(temp_list,','); temp_list := null; if to_number(cur_rec) < to_number(anchor_rec) then tempchar := cur_rec; cur_rec := anchor_rec; anchor_rec := tempchar; end if; for counter in anchor_rec..cur_rec loop listx.add_to_list(temp_list,to_char(counter)); end loop; wipe_list(temp_list,cur_block);
/* The user held Alt when they clicked */ elsif :system.mouse_button_shift_state = 'Alt+' then
cur_rec := get_block_property(cur_block,CURRENT_RECORD); temp_list := name_in(cur_block||'_header.select_list'); status := listY.sort_num(temp_list); /* determine anchor rec */ for counter in 1..listx.counts(temp_list) loop if to_number(listx.peel(temp_list,counter)) < to_number(cur_rec) then anchor_rec := to_number(listx.peel(temp_list,counter)); end if; end loop; /* build new items list (note: use temp_list3) */ for counter in to_number(anchor_rec)+1..to_number(cur_rec) loop listx.add_to_list(temp_list3,to_char(counter)); end loop; wipe_list(temp_list3,cur_block); /* patch for row 1 */ if anchor_rec = 1 then go_record(1); if name_in(cur_block||'.selected') is null then wipe_list('1',cur_block); end if; end if;
end if; --button
Declare
Item_ID Item;
Begin
Item_ID := Find_Item('STUFF.NULL_ITEM'); IF NOT ID_NULL(item_id) THEN
Go_Item(Item_ID);
End If;
End;
end if; --selected exists
END;
END;
Scott Dart wrote:
> > If I have a multi-record block, how can I select multiple lines > (cntrl-click, shift-click type of multi selection). There are a number of > applications for which this would be useful--copy, paste, etc. Seems like a > very basic concept that is not supported. It would allow code to be > executed on what would basically be a user-defined cursor. any ideas? > > thanks > > scott-dart_at_uiowa.eduReceived on Sun Apr 20 1997 - 00:00:00 CEST